seigniory has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use LWP::UserAgent; # $artist = "Pearl Jam"; # These two entries work because +the repsonse from # $album = "Ten"; # the post is a standard HTML pag +e $artist = "Catherine Wheel"; # These two entries do not work b +ecause the response $album = "Chrome"; # from the post is a 302 redirect + and its not being # followed. It's not a POST redi +rect, its a post which # triggers a GET redirect. $ua = new LWP::UserAgent; $ua -> agent("YoYoMa/".$ua -> agent); push @{ $ua->requests_redirectable }, 'POST'; # This line do +esn't seem to make a difference. It fails with/without it. $url = "http://www.amazon.com/exec/obidos/search-handle-form/ref=s +_sf_pm/002-2036334-1552026"; $req = new HTTP::Request('POST',$url); $req->content_type('application/x-www-form-urlencoded'); $req->content("page=1&index=music&field-artist=".$artist."&field-t +itle=".$album."\n"); $res = $ua->request($req); if ($res->is_success) { print $res->content; } else { print "Redirect not followed."; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GET redirect after a POST with LWP
by eserte (Deacon) on May 18, 2004 at 13:57 UTC |