in reply to Log into a screen and getting a response

use WWW::Mechanize; my $username = 'user'; my $password = 'pass'; my $url = 'http://www.xyz.com/Login.aspx'; my $mech = WWW::Mechanize->new(autocheck => 1); $mech->get( $url ); $mech->form_name("login form name"); $mech->field("username", $username); $mech->field("password", $password); $mech->click("login button/submit name"); $mech->content() =~ /sm.th. from Track.aspx/ and print "logged in\n" __END__
Update: you may want to use mech-dump - like this:
mech-dump "http://some.web-site.com/login.html"
in order to see the input fields.


Replies are listed 'Best First'.
Re^2: Log into a screen and getting a response
by Anonymous Monk on Mar 28, 2005 at 08:57 UTC
    Thanks for the code. I have downloaded the Mechanize 1.12 version from net. When I executed the command "perl Makefile.PL", I encountered the following warnings:
    Warning: prerequisite HTML::Form 1.038 not found at /opt/perl/lib/5.6.1/ExtUtils/MakeMaker.pm line 343.
    Warning: prerequisite HTML::TokeParser 2.28 not found at /opt/perl/lib/5.6.1/ExtUtils/MakeMaker.pm line 343.
    Warning: prerequisite HTTP::Request 1.3 not found at /opt/perl/lib/5.6.1/ExtUtils/MakeMaker.pm line 343.
    Warning: prerequisite LWP 5.76 not found at /opt/perl/lib/5.6.1/ExtUtils/MakeMaker.pm line 343.
    Warning: prerequisite LWP::UserAgent 2.024 not found at /opt/perl/lib/5.6.1/ExtUtils/MakeMaker.pm line 343.
    Warning: prerequisite Test::More failed to load: Can't locate Test/More.pm in @INC (@INC contains: /opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi /opt/perl/lib/5.6.1 /opt/perl/lib/site_perl/5.6.1/PA-RISC1.1-thread-multi /opt/perl/lib/site_perl/5.6.1 /opt/perl/lib/site_perl .) at (eval 33) line 3.
    Warning: prerequisite URI 1.25 not found at /opt/perl/lib/5.6.1/ExtUtils/MakeMaker.pm line 343.

    What should be done to eliminate these warnings?
    Akhil