perl.crazy has asked for the wisdom of the Perl Monks concerning the following question:

Dear All, I am wiling to aumtomate a website using LWP. But the output is error message "Moved Temporarily". My program is as follows:
******************************************** #!/usr/bin/perl my $URLtoPostTo="http://tools.immuneepitope.org/tools/bcell/bcell_Pred +iction"; my %Fields = ( "swId" => "P02185", "sequence" => ">sp|P02185|MYG_PHYCA Myoglobin OS=Physeter catodon G +N=MB PE=1 SV=2 MVLSEGEWQLVLHVWAKVEADVAGHGQDILIRLFKSHPETLEKFDRFKHLKTEAEMKASE DLKKHGVTVLTALGAILKKKGHHEAELKPLAQSHATKHKIPIKYLEFISEAIIHVLHSRH PGDFGADAQGAMNKALELFRKDIAAKYKELGYQG", "method" => '5' ); use strict; use LWP::UserAgent; use HTTP::Request::Common; my $Browser = new LWP::UserAgent; if($BrowserName) { $Browser->agent($BrowserName); } my $Page = $Browser->request(POST $URLtoPostTo,\%Fields); if ($Page->is_success) { print $Page->content; } else { print "HTTP request failure \n"; print $Page->message; } **********************************************************

Please let me know if there is any solution for this program. I am not able to find out.

Replies are listed 'Best First'.
Re: LWP problem
by Gangabass (Vicar) on Sep 18, 2009 at 11:52 UTC

    You should use:

    push @{ $Browser->requests_redirectable }, 'POST';

    but i'm strongly recommend you to use WWW::Mechanize because life is short :-)

Re: LWP problem
by Anonymous Monk on Sep 18, 2009 at 11:31 UTC
Re: LWP problem
by venkatesan_G02 (Sexton) on Sep 18, 2009 at 11:59 UTC
    Try this code. It's retrieving the page but the link itself is throwing error "Error: please select a prediction method!".
    #!C:/perl/bin/perl.exe use LWP::UserAgent; use HTTP::Request::Common; my $url = 'http://tools.immuneepitope.org/tools/bcell/bcell_Prediction +'; # Set up the ntlm client and then the base64 encoded ntlm handshake me +ssage my $ua = new LWP::UserAgent(); $request = GET $url; print "--Performing request now...-----------\n"; $response = $ua->request($request); print "--Done with request-------------------\n"; if ($response->is_success) {print "It worked!->" . $response->code . " +\n"} else {print "It didn't work!->" . $response->code . "\n"} + #Save the case to the local PC $response = $ua->mirror($url,"c:/test/perlmonks.htm");
    I would suggest using WWW::IE::MechanizeWWW::IE::Mechanize or WWW::SeleniumWWW::Selenium as the page uses Javascript.
      Maybe you can replicate the error if you actually POST instead of GET :=D
        It still gives the same result. It is fetching the page.