in reply to Howto fill in username and password in a popup cookie with Perl

Hey

I have a few thoughts. One is to enable cookies for Mech. That goes something like this:

$mech->cookie_jar(HTTP::Cookies->new( file =>"mechcookies.txt", autosave => 1));
If that and swapping those two lines isn't working, I do have one idea. I had a site I was scraping recently (with their permission), and I was having trouble getting Mech to log in. What eventually worked with was this:
my @args = (Authorization => "Basic " .MIME::Base64::encode('USER:PASS +')); $mech->get('https://www.BlahBlah.com/secure-bin/Blahclub/login_redirec +t.cgi', @args); $mech->get('http://www.BlahBlah.com/ThingIWant')
I think part of the trick was making sure that I was sending that username/password combination to the login-script. Though for all I know, once I was calling the get on that url, it was the credentials statement that made it work (logging-in with Mech is pretty new to me).

If you're having trouble locating the appropriate url for the login, I've had a lot of luck with Live HTTP Headers for Firefox, which basically tracks everything your browser does (when it's on), and has helped me mimic that with Mech. Good luck!

Hays

Update: Cookies may be on by default in Mech, but having the hard-copy lets you see what's there (if anything).

Replies are listed 'Best First'.
Re^2: Howto fill in username and password in a popup cookie with Perl
by paulehr (Sexton) on Nov 15, 2006 at 02:13 UTC

    Hello,
    I stumbled across this node when i was trying to tackle the same kind of problem as the original poster.

    My Question is why did you need to add MIME::Base64 into the mix?. Granted it worked for me but i just don't understand why I had to do it instead of using the credentials method supplied with mech.

    Thanks for the help!