GHMON has asked for the wisdom of the Perl Monks concerning the following question:

Hi i wrote a code to login a web page but when i took output , show me authentication page . this is my code

use strict; use warnings; use strict; use WWW::Mechanize; use LWP ; use HTTP::Cookies; my $url = 'http://2010.tct.ir/CustomerSignIn.aspx'; my $username = 'X'; my $password = 'Y'; my $mech = WWW::Mechanize->new() ; $mech->cookie_jar(HTTP::Cookies->new()) ; $mech->post($url) ; $mech->form_id('Form1') ; $mech->field('LoginControl$FileIDTextBox'=> $username) ; $mech->field('LoginControl$PasswordTextBox'=>$password) ; $mech->submit ('LoginControl$ButtonSignInn') ; print $mech->content() , "\n" ;

Replies are listed 'Best First'.
Re: Problem in login in web page (JS)
by LanX (Saint) on Sep 28, 2018 at 15:28 UTC
    This page is using JavaScript, but WWW::Mechanize can't handle JS.

    > Please note that Mech does NOT support JavaScript, you need additional software for that. Please check "JavaScript" in WWW::Mechanize::FAQ for more.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      tnx

      Hi again what is your opinion about this code !!!!!

      use strict; use warnings; use strict; use WWW::Mechanize; use LWP ; use HTTP::Cookies; my $url = 'http://2010.tct.ir/CustomerSignIn.aspx'; my $username = 'X'; my $password = 'Y'; my $mech = WWW::Mechanize->new( agent=>"Mozilla/5.0 (X11; U; Linux i68 +6; en-US; rv:1.7) Gecko/20040918 Firefox/0.9.3 ") ; my $cookies = HTTP::Cookies->new(file => './lwp_cookies.dat' , autosav +e => 1 ,) ; $mech->cookie_jar($cookies) ; $mech->post($url) ; $mech->form_id('Form1') ; $mech->field('LoginControl$FileIDTextBox'=> $username) ; $mech->field('LoginControl$PasswordTextBox'=>$password) ; $mech->submit ('LoginControl$ButtonSignInn') ; print $mech->content() , "\n" ;