in reply to Navigating with WWW::Mechanize across intermediate pages

It is possible that the server you are visiting is sending "redirect" headers.

Check out the $mech->redirect_ok() option, which instructs your virtual browser (WWW::Mechanize) to follow redirects.

update 1: a simpler approach may be to parse the header yourself looking for a URI to follow. Try the following on one of your magically redirecting pages:

use WWW::Mechanize; my $mech = WWW::Mechanize->new( quiet => 1 ); $mech->get( "http://www.mysite.com/index.html" ); die( "Error getting page" ) if ( ! $mech->success() ); print( $mech->response->headers_as_string );

or alternatively if you want to see the entire message, headers included, for debugging purposes, replace ->headers_as_string with ->as_string..

Replies are listed 'Best First'.
Re^2: Navigating with WWW::Mechanize across intermediate pages
by perrin (Chancellor) on Jun 22, 2005 at 08:23 UTC
    Mech already follows valid redirects automatically. These are probably JavaScript or Meta-Refresh tags.