Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Finding a redirect's URL

by wog (Curate)
on Nov 23, 2001 at 22:25 UTC ( [id://127156]=note: print w/replies, xml ) Need Help??


in reply to Finding a redirect's URL

LWP allows you to make a request without LWP following redirects, etc. with the simple_request method of LWP::UserAgent. For example:

my $request = HTTP::Request->new("GET", "http://cnn.com/europe"); my $response = $ua->simple_request($request); print $response->header("Location"), "\n"; # http://europe.cnn.com

Also the HTTP::Response class has a previous method to get the previous response in a chain of responses (as occurs when LWP follows redirects):

my $request = HTTP::Request->new("GET", "http://cnn.com/europe"); my $response = $ua->request($request); print $response->previous->header("Location"), "\n"; # http://europe.cnn.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://127156]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-26 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found