Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Finding a redirect's URL

by wog (Curate)
on Nov 23, 2001 at 22:25 UTC ( #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? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2022-11-26 12:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?