Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: redirection issue with WWW::Mechanize

by Special_K (Monk)
on May 23, 2014 at 05:54 UTC ( [id://1087158]=note: print w/replies, xml ) Need Help??


in reply to Re^3: redirection issue with WWW::Mechanize
in thread redirection issue with WWW::Mechanize

OK, I solved it. The following does work:

$agent->follow_meta_redirect;


but only if you do NOT also have this in your code:

$agent->requests_redirectable( [] );


Alternately, you can also just parse the content returned by:

$post_response->decoded_content()


when the page containing the redirect is first loaded, and get the redirect URL from that. Again, the key is that you must NOT have:

$agent->requests_redirectable( [] );


in your code. I think it's strange that if you enable redirects you still must manually retrieve the redirect URL, and if you disable redirects then even manually retrieving the URL doesn't work.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-24 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found