Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: WWW::Mechanize submission problem

by no21 (Sexton)
on Feb 05, 2006 at 13:22 UTC ( [id://528065]=note: print w/replies, xml ) Need Help??


in reply to Re: WWW::Mechanize submission problem
in thread WWW::Mechanize submission problem

I agree. Sorry about that.

This sub is what is currently working to log me in to Yahoo with ActivePerl:

sub login{ print "Logging in to Yahoo..."; #set url to page requiring login and password my $url = 'http://login.yahoo.com/config/login?.done=http://fantas +ysports.yahoo.com&.src=spt&.intl=us'; $mech->get( $url ) or die("Could not get $url\n"); #these two fields were specfic to the Yahoo login HTML field name +s #for login and password. $mech->field("login", 'my_username'); $mech->field("passwd", 'my_password'); $mech->click(); print "Done.\n"; }#sub login


And the original error message was actually with the $mech->field() methods. They failed on the Linux box first. After re-reading the documentation on CPAN, I tried a different way of setting the values for those fields, and I was able to fix that problem by using this code instead of the two $mech->field lines above above:

$mech->set_visible( "my_username", "my_password");


However, apparently the submission is not working because I am not downloading the HTML content that should be there after logging in. It actually downloads an HTML page telling me that I haven't logged in.

So now my linux box code looked like this:

sub login{ print "Logging in to Yahoo..."; #set url to page requiring login and password my $url = 'http://login.yahoo.com/config/login?.done=http://fantas +ysports.yahoo.com&.src=spt&.intl=us'; $mech->get( $url ) or die("Could not get $url\n"); #these two fields were specfic to the Yahoo login HTML field name +s #for login and password. $mech->set_visible( "my_username", "my_password"); $mech->click(); print "Done.\n"; }#sub login


That's when I began Dumping the form to make sure the login and password fields were actually being set to the correct values, and they are.

So tried a few other submission methods other than $mech->click(). Like the following:
$mech->submit();
...and...
my $button = $mech->current_form()->find_input(undef, "submit"); $mech->click_button(input => $button)

None of these worked. Again, any help would be greatly appreciated.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found