http-equiv=refresh with Mechanize

Peter Stevens <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Hi folks,

I am logging in to a particular site using the following code:

    $mech->field($usernameField,$user);
    $mech->field($passwordField,$pswd);
    $mech->click();

    if (!$mech->success) {
        warn($CLASS, "Could not login, message = " . $mech->response->status_line) ;
        return 0;
    }
    print "login OK" ;
    return 1;
      

Most of the time, this works just fine, but every once in while I get 
the following content back:

    <HEAD>
    <meta http-equiv=refresh content=0;url="/where/I/really/want/to/be">
    <TITLE> Login Screen </TITLE>
    </HEAD>
    <BODY link="#ff6600" vlink="#ff9900">

I can of course catch this and submit the new URL, but doesn't mech 
usually deal with this kind of stuff? Or does it only http redirects?

Thanks in advance,

Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.