http://www.perlmonks.org?node_id=985122

kiran.b.naik has asked for the wisdom of the Perl Monks concerning the following question:

Hi Experts, I am trying to login to a secure website (here using GMAIL) using perl script. PFB script I am using. This script executes fine but it is not able to login, when I open the outfile it shows main login screen only. its not going next page. Please help me here...
use strict; use warnings; use strict; use WWW::Mechanize; use HTTP::Cookies; my $outfile = "out2.htm"; my $url = "https://accounts.google.com/ServiceLogin?service=mail&passi +ve=true&rm=false&continue=http://mail.google.com/mail/&scc=1&ltmpl=de +fault&ltmplcache=2"; my $username = "<user>"; my $password = "<PWD>"; my $mech = WWW::Mechanize->new(); $mech->cookie_jar(HTTP::Cookies->new()); $mech->get($url); $mech->form_name('login_form'); $mech->field("Username", $username); $mech->field("Password", $password); $mech->submit_form(form_number => 1); my $output_page = $mech->content(); open(OUTFILE, ">$outfile"); binmode(OUTFILE, ":utf8"); print OUTFILE "$output_page"; close(OUTFILE);