in reply to Redirect with Mechanize

http://www.nature.com/nature/current_issue 302s to http://www.nature.com/nature/current_issue/ which 302s to http://www.nature.com/nature/current_issue/index.html

That URL generates a webpage which says...

... <meta http-equiv="Refresh" content="0;url=/nature/journal/v449/n7161/" + /> </head> <body onLoad="location='/nature/journal/v449/n7161/'"> </body> </html>

...I'm not sure if WWW::Mechanize follows meta refreshes, but even if it does this particular meta refresh seems a bit bogus -- the url portion of the content attribute needs to be fully qualified.

But since browsers seem to respect it (it seems to work in firefox even with javascript turned off) WWW::Mechanize could probably be improved to respect it as well.

Replies are listed 'Best First'.
Re^2: Redirect with Mechanize
by karavay (Beadle) on Sep 30, 2007 at 23:05 UTC
    If its an automated redirect between the pages (which is quite common) with, which mechanize cannot cope, add this to your code:

    after this :

    $mech->follow_link(n=>4 ); #4 is your link number
    or
    $mech->submit();# or form submit

    add this (to follow the redirection correctly):

    $mech->follow_link(n=>0);



    you can try accessing the root of the page and then following the link.