I am trying out WWW::Mechanize for the first time, and am attempting step-by-step to use it on http://www.networksolutions.com. Despite trying explicity to login exactly as I do with a browser, it takes the Mech to a failure screen to login again, whereas the browser gets through. There are 2 idiosyncrasies about it which perhaps I need to do something special for: 1. It uses https, and seems to have a way of setting a new SessionID for your login session in the URL. 2. It goes to a jhtml page; I'm not sure if that's making any difference.
I do have IO::Socket::SSL and Crypt:SSLeay both installed and used.
Here is simplified source:
-----------------------BEGIN login_netsol.pl--------------------------
#!/usr/bin/perl -w
#Configuration:######################### my $NETSOL_URL="http://www.netsol.com/"; my $USERNAME="correctlogin"; my $PASSWORD="correctpass"; #End Configuration######################
# turn on perl's safety features use strict; use warnings;
# One or both of these are required for https use IO::Socket::SSL; use Crypt::SSLeay;
# create a new mech use WWW::Mechanize; my $agent = WWW::Mechanize->new();
# Retrieve main page
$agent->get($NETSOL_URL);
# Login
$agent->submit_form(
form_name => 'login', #aka form_number=>2, which I also tried
fields => {
username => $USERNAME,
password => $PASSWORD,
isAutoLoginEnabled => 'off'
}
);
my $url = $agent->uri; print "New URL: $url\n"; system('/usr/bin/mozilla', "$url");
exit(0);
------------------------------EOF-------------------------
The general format of the uri I get when successfully logging in is:
https://www.networksolutions.com/en_US/manage-it/view-account.jhtml;jsessionid= ABCDEFGHIJKLMNOPQRSTUVW?accountId=12345678&home=true&_requestid=1234567
(with the letter and number strings different each time) The url the mech draws up when logging in is:
https://www.networksolutions.com/en_US/manage-it/index.jhtml?_DARGS=/en_US/ index.jhtml.2
Which is an error page with another login prompt for you to try again. And yes, I did quintuple-check that I was using the right username/password. ;) There are also a schlew of hidden variables in the form which it only complains as being read-only when I try to set them here. The cookie jar is active by default, right? Anybody dealt with networksolutions before?
Thanks for your guidance.
-- Stephan