Thanks for quik respose. Actually, I posted wrong code. Below is the code I am using. I do use $browser->post(...). But, I cannot get result page. Any clue?
#!/usr/bin/perl -w use strict; use LWP; my $browser = LWP::UserAgent->new; my $response = $browser->post('http://www.abebooks.com', ["sts" => "t", "an" => "", "tn" => "Codex Seraphinianus", "kn" => "", "isbn" => "" ] ); die "Error: ", $response->status_line, "\n" unless $response->is_success; my $out_file = "result_seraph.html"; # where to save it open(OUT, ">$out_file") || die "Can't write-open $out_file: $!"; binmode(OUT); print OUT $response->content; close(OUT); print "Bytes saved: ", -s $out_file, " in $out_file\n"; --- On Mon, 6/13/11, sylva...@comcast.net <sylva...@comcast.net> wrote: > From: sylva...@comcast.net <sylva...@comcast.net> > Subject: Re: LWP post, Cannot get result page > To: "Gary Yang" <garyya...@yahoo.com>, libwww@perl.org > Date: Monday, June 13, 2011, 5:42 PM > use $browser->post(...) instead > of ->get. > > -----Original Message----- From: Gary Yang > Sent: Monday, June 13, 2011 8:36 PM > To: libwww@perl.org > Subject: LWP post, Cannot get result page > > I have been trying to learn LWP Post, by going through an > examples on the web. Perl & LWP. > I try to search AbeBooks for the book "Codex Seraphinianus" > from the main page (AbeBooks). Here is the code that I am > using: > > > #!/usr/bin/perl -w > > use strict; > use LWP > > my $cookie_jar = HTTP::Cookies->new(file => > "lwp_cookies.dat", autosave => 1); > > my $browser = LWP::UserAgent->new; > > $browser->cookie_jar($cookie_jar); > > > my $response = $browser->get('http://www.abebooks.com', > ["sts" => "t", > "an" => "", > "tn" => "Codex Seraphinianus", > "kn" => "", > "isbn" => "" > ] > ); > > die "Error: ", $response->status_line, "\n" unless > $response->is_success; > > my $out_file = "result_seraph.html"; # where to save it > open(OUT, ">$out_file") || die "Can't write-open > $out_file: $!"; > > binmode(OUT); > print OUT $response->content; > close(OUT); > > > > But this just sends me back the content of the search page > not the result page. Anyone knows what the problems are? > Anyone can show me a real working code of LWP post? > Thanks. > > >