#!/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 page $artist = "Catherine Wheel"; # These two entries do not work because the response $album = "Chrome"; # from the post is a 302 redirect and its not being # followed. It's not a POST redirect, its a post which # triggers a GET redirect. $ua = new LWP::UserAgent; $ua -> agent("YoYoMa/".$ua -> agent); push @{ $ua->requests_redirectable }, 'POST'; # This line doesn'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-title=".$album."\n"); $res = $ua->request($req); if ($res->is_success) { print $res->content; } else { print "Redirect not followed."; }