This question has been asked a number of times before and I've read them and actually tried doing it once a while back (different project but even then, it never did it right. It never logged in and stayed logged in).
I want to create a script that logs into Neopets.com. It has a two page login (enter your username on page 1, enter your password on the page it redirects you to). I need to STAY logged in with the cookie or session that they send out so I can run a few other page scrapes.
What module(s) would be best to login with 2 forms and stay logged in so I can navigate with my bot where it's supposed to go?
---------------
After doing a little looking around, looks like it could do it. So here's the next question..
After reading some of the docs on this module it shows how to follow_link as if you were following an HTML link.
This is a two page form, how do I then submit the information on the next page? Would I just put in the next form code (as seen below)?
I want to create a script that logs into Neopets.com. It has a two page login (enter your username on page 1, enter your password on the page it redirects you to). I need to STAY logged in with the cookie or session that they send out so I can run a few other page scrapes.
What module(s) would be best to login with 2 forms and stay logged in so I can navigate with my bot where it's supposed to go?
---------------
After doing a little looking around, looks like it could do it. So here's the next question..
After reading some of the docs on this module it shows how to follow_link as if you were following an HTML link.
This is a two page form, how do I then submit the information on the next page? Would I just put in the next form code (as seen below)?
Code:
#!/usr/bin/perl
use warnings;
uses strict;
use CGI qw/:standard/;
use [URL unfurl="true"]WWW::Mechanize;[/URL]
my $mech = [URL unfurl="true"]WWW::Mechanize->new();[/URL]
$mech->submit_form(
form_number => 1,
fields => {
username => 'user'
}
);
####
# the previous form redirects us to a new page/form. This
# should fill out that form the, right?
####
$mech->submit_form(
form_number => 1,
fields => {
password => '12345'
}
);
####
# at this time, cookies should be saved allowing me to use
# Mechanize to pull back ANY $url I want on Neopets.com.
####