I want to scan a list of URL's for bad ones. The following is largely from 'perldoc lwp'. The particular bad URL is being redirected to a custom 404 page, so it returns 200 instead. Is there some way to know if the request has been redirected? If so, is there a way to know *why* it was redirected, i.e., get that original result code?
/g #!perl.exe -w $url = "http://www.eskimo.com/bad_url.blah"; # Don't look at that page, it is traumatic # Create a user agent object use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->agent("AgentName/0.1 " . $ua->agent); # Create a request my $req = new HTTP::Request HEAD => $url; $req->content_type('application/x-www-form-urlencoded'); $req->content('match=www&errors=0'); # Pass request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ($res->is_success) { print $res->content; } else { print "Bad luck this time\n"; } print $res->code; __END__ Result: D:\PERL>verifypages.pl 200 =========================================== FWIW: Here's a one-liner to retrieve a webpage (paste it to the command line!): Windows: perl -MLWP::Simple -e "getprint \"http://www.msnbc.com/\";" NotWindows: perl -MLWP::Simple -e 'getprint "http://www.msnbc.com/";' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]