Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
OK, so I'm using WWW::Mechanize to try to login to a site so that I can parse some of the content on the site. Unfortunately, it looks like I'm not successfully 'logging in'.
The form on the site looks like this:
<form onSubmit="return validLogin( this );" action="/servlet/LoginServ +let" METHOD="post" name="enterLogin"> <input type="text" tabindex="1" size="8" name="loginId"> <input type="password" tabindex="2" size="8" name="Password"> <input TYPE="hidden" name="action" value="loginFrame"> <input type="hidden" name="app" value=""> <input type="hidden" name="sessType" value="new"> <input type="image" tabindex="3" src="/homepage/gobutton.gif" border=" +0"> </form>
I used the update_html method to remove "onSubmit=return validLogin( this );" so that it doesn't call the javascript (it just changes the username/password to uppercase).
Here is what my code looks like:
The code above prints the login page ....meaning, it didn't really log me in.use LWP::Simple; use WWW::Mechanize; my $m = WWW::Mechanize->new( autocheck=>1 ); $agent->cookie_jar(HTTP::Cookies->new); # point to the url of the login form $m->get("http://www.mydomain.com/servlet/LoginServlet"); my $html = $m->content; $html =~ s[onSubmit="return validLogin\( this \);"][]g; $m->update_html($html); $m->submit_form( form_name => "enterLogin", fields => { loginId=> "XXXXXXX", Password=> "YYYYYYY", action=> "loginFrame", app=> "", sessType=> "new" } ); print "success?:"; print $m->success(); print "\n"; my $url1 = "http://www.mydomain.com/private/Servlet?var1=apples&var2=o +ranges"; $m->get($url1); print $m->content;
Any ideas why this isn't working? Am I supposed to be doing something with the input/image tag?
thank you!
2006-06-08 Retitled by GrandFather, as per Monastery guidelines
Original title: 'Not logging in'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script using WWW::Mechanize fails to log in
by arkturuz (Curate) on Jun 08, 2006 at 07:50 UTC | |
by Anonymous Monk on Jun 08, 2006 at 07:56 UTC | |
by Joost (Canon) on Jun 08, 2006 at 10:00 UTC | |
| |
by arkturuz (Curate) on Jun 08, 2006 at 08:11 UTC | |
by Anonymous Monk on Jun 08, 2006 at 09:47 UTC | |
by arkturuz (Curate) on Jun 08, 2006 at 10:03 UTC | |
|
Re: Script using WWW::Mechanize fails to log in
by wfsp (Abbot) on Jun 08, 2006 at 12:08 UTC | |
|
Re: Script using WWW::Mechanize fails to log in
by planetscape (Chancellor) on Jun 09, 2006 at 03:17 UTC | |
|
Re: Script using WWW::Mechanize fails to log in
by Anonymous Monk on Jun 08, 2006 at 10:53 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |