Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Please Help! Submit User Login Form...

by jdlev (Scribe)
on Nov 04, 2013 at 18:35 UTC ( #1061173=perlquestion: print w/ replies, xml ) Need Help??
jdlev has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use WWW:Mechanize to no avail. I don't think it's working because it isn't a form that's submitting (at least I don't think it is...I'm not familiar with how to submit javascript forms?)

Here's the html for information I'm trying to submit and login with:

<tbody> <tr> <td colspan="2" id="login +Error" class="loginErrorText" align="center"> </td> </tr> <tr> <td width="37%" align="ri +ght" class="loginText"> Email: </td> <td width="50%" align="le +ft" class="loginTextInput"> <input type="text" id= +"txtUserName" name="email" style="width:150px;"/> </td> </tr> <tr> <td align="right" class=" +loginText"> Password: </td> <td align="left" class="l +oginTextInput"> <input id="txtPassword +" type="password" style="width:150px;"/> </td> </tr> <tr> <td class="login-text" al +ign="right"> Remember Me <input type="checkbox" + id="ckRememberMe" name="ckRememberMe" value="Remember Me"/> <div id="remember-me"> <a href="http://www +.draftstreet.com/ForgotPassword.aspx" class="login-text-remember"> Forgot Password? </a> </div> </td> <td align="right" style=" +padding-right:23px;padding-top:10px;"> <a href="javascript:vo +id(0);" id="btnSubmit"> <img src="http://23 +404f625988819b4d55-1a66a67fd18c432b98277c46ef65a97e.r10.cf1.rackcdn.c +om/button_signin.png" alt="Submit" border="0"/> </a> </td> </tr> <tr style="height:20px;"> <td colspan="2"> </td> </tr> </tbody>

And here's my script:

use WWW::Mechanize; print "Enter User ID: "; $username = <>; print "Enter Password: "; $password = <>; my $mech = WWW::Mechanize->new(); $url = "http://www.draftstreet.com/default.aspx"; print $url; $mech->get( $url ); $mech->field(txtUserName,$username); $mech->field(txtPassword,$password);
I love it when a program comes together - jdhannibal

Comment on Please Help! Submit User Login Form...
Select or Download Code
Re: Please Help! Submit User Login Form...
by LanX (Canon) on Nov 04, 2013 at 18:38 UTC
    That's a FAQ (once per week?)

    Did you search for " WWW::Mechanize javascript "?

    Did yoy read the docs of WWW::Mechanize ?

    > Please Help!

    Plz read! :)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re: Please Help! Submit User Login Form...
by ww (Bishop) on Nov 04, 2013 at 20:45 UTC
    ...and, please, next time you have some heavily indented html to post, do everyone a favor, and reduce the indentation (to something like 2 or 3 spaces).

    What you posted appears to have something like 40-space indents. That's a tad of overkill.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1061173]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-12-26 10:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls