A
Antwerp
Hi,
I'm trying to create a script that automatically logs in to a website, and
then parses the index (which is unavailable without first logging on). I'm
having difficulties, but I'm not exactly sure where they might lie.
I know I need to enable cookies to login, and I believe I have done so. I
also recognize that I need to find and submit the appropriate form data - I
*think* am doing this correctly too. However, once I submit the form data, I am
unable to print, load, or view the "secure" page. I would appreciate any help;
-------
my $mech = WWW::Mechanize->new( autocheck => 1 );
$mech->agent_alias( 'Windows IE 6' );
$mech->cookie_jar(HTTP::Cookies->new
(
file => "cookies.txt",
autosave => 1,
) );
###The above should allow for the storage and sending of cookies###
$mech->get( $url ); #Getting the desired page
#(automatically redirects to the login page);
print $mech->content(); #Printing the content of the page
#(Which, because of the redirect,
# is the login screen. I pipe the output to an
# output.html file for verification.
$mech->field( $login_field_name, $usna ); #this should be setting the login
field values
$mech->field( $password_field_name, $pawo ); #this should be setting the
password field values
$mech->submit(); #this should submit the form, causing
#a redirect to the proper index for logged in users
print $mech->content(); #Question:
#Shouldn't this show the new content of the page -
#that is, the member index? Why does it not do so?
-------
I appreciate any help or suggestions,
Thanks,
AntWerp
I'm trying to create a script that automatically logs in to a website, and
then parses the index (which is unavailable without first logging on). I'm
having difficulties, but I'm not exactly sure where they might lie.
I know I need to enable cookies to login, and I believe I have done so. I
also recognize that I need to find and submit the appropriate form data - I
*think* am doing this correctly too. However, once I submit the form data, I am
unable to print, load, or view the "secure" page. I would appreciate any help;
-------
my $mech = WWW::Mechanize->new( autocheck => 1 );
$mech->agent_alias( 'Windows IE 6' );
$mech->cookie_jar(HTTP::Cookies->new
(
file => "cookies.txt",
autosave => 1,
) );
###The above should allow for the storage and sending of cookies###
$mech->get( $url ); #Getting the desired page
#(automatically redirects to the login page);
print $mech->content(); #Printing the content of the page
#(Which, because of the redirect,
# is the login screen. I pipe the output to an
# output.html file for verification.
$mech->field( $login_field_name, $usna ); #this should be setting the login
field values
$mech->field( $password_field_name, $pawo ); #this should be setting the
password field values
$mech->submit(); #this should submit the form, causing
#a redirect to the proper index for logged in users
print $mech->content(); #Question:
#Shouldn't this show the new content of the page -
#that is, the member index? Why does it not do so?
-------
I appreciate any help or suggestions,
Thanks,
AntWerp