prakash.ramesh has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I am trying to login to a boadband login webpage using perl WWW::Mechanize module. But the code ends up remaining in the login page. Here is my code. I tried two different codes.
#!C:\Perl64\bin\perl.exe use strict; use WWW::Mechanize; use HTTP::Cookies; my $outfile = "out.htm"; my $url = "https://loginban.tataindicombroadband.in:8443"; my $username = "username"; my $password = "password"; my $mech = WWW::Mechanize->new(); $mech->cookie_jar(HTTP::Cookies->new()); $mech->get($url); $mech->form_name('authenticateForm'); $mech->form_number(1); $mech->field(username => $username); $mech->field(password => $password); $mech->click("Submit"); my $output_page = $mech->content(); open(OUTFILE, ">$outfile"); print OUTFILE "$output_page"; close(OUTFILE);
#!C:\Perl64\bin\perl.exe use strict; use WWW::Mechanize; use HTTP::Cookies; my $outfile = "out.htm"; my $url = "https://loginban.tataindicombroadband.in:8443"; my $username = "username"; my $password = "password"; my $mech = WWW::Mechanize->new(); $mech->cookie_jar(HTTP::Cookies->new()); $mech->get($url); my $result = $mech->submit_form( form_name => 'authenticateForm', fields => { username => $username, password => $password, } ); die "SUBMIT failed\n" unless $result->is_success my $output_page = $mech->content(); open(OUTFILE, ">$outfile"); print OUTFILE "$output_page"; close(OUTFILE);
|
|---|
| Replies are listed 'Best First'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Re: Unable to login to a secure webpage
by Gangabass (Vicar) on Aug 16, 2011 at 05:42 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Your site doesn't work for me now so don't know what's wrong with it. But you must check does it works with JavaScript disabled (in the browser)? Also there is no need to use HTTP::Cookies because WWW::Mechanize using it by default. And of course you can use $mech->save_content() to save response content. | [reply] [d/l] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
by prakash.ramesh (Initiate) on Aug 16, 2011 at 21:21 UTC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hi,
I tried with with JavaScript disabled (in the browser) and it did not work. Here is the html contnet of the web page.
| [reply] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||