Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Is it possible to get the redirected URL?

by Kanji (Parson)
on Dec 15, 2005 at 05:21 UTC ( #516864=note: print w/ replies, xml ) Need Help??


in reply to Is it possible to get the redirected URL?

LWP (or WWW::Mechanize) would let you load Page B and automatically follow the HTTP redirects, with the final URL being available to you in the uri method.

Where things get tricky is if any of the pages handle redirects via meta refresh or JavaScript.

The former is pretty easy to code around, but the latter usually requires prior knowledge of what the JavaScript is/does so that you can explictly tailor your code to handle it (and then hope no one changes it).

If you do expect a lot of JavaScript redirects, a better alternative might be to use either Win32::IE::Mechanize or Mozilla::Mechanize, as both browsers have JavaScript engines and should be able to follow those redirects automatically (but I've used neither module, so can't confirm this).

    --k.



Comment on Re: Is it possible to get the redirected URL?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-12-28 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (179 votes), past polls