Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Howto fill in username and password in a popup cookie with Perl

by hgolden (Pilgrim)
on Sep 22, 2006 at 14:44 UTC ( [id://574383]=note: print w/replies, xml ) Need Help??


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!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2025-05-24 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.