Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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

Replies are listed 'Best First'.
Re: Please Help! Submit User Login Form...
by LanX (Chancellor) 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 (Archbishop) 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?
[Corion]: I still somewhat wonder if it were worthwhile to replace init / systemd by make with a simple? Makefile listing the dependencies ...
[Discipulus]: i have a different opinion: automation is always worth: first i can use Perl (and this is good), then later you can reuse parts to automate others tasks. My $boss everytime say:'how much time you spend doing this?' So generally i present a perl solution
[Corion]: Discipulus: Yes, but the chart gives some limits on whether it's really worth spending time for saving your time. If you gain enjoyment, automating is still great, but it doesn't save time ;)
[Discipulus]: Corion are you would able to realize such thing? O_O
[Corion]: In the same vein I have a script that automates Firefox to enter some data into another system. It's not faster than the people using the script if they were to do it manually, but they prefer not having to check the data and not having typos when ...
[Corion]: ... entering the data

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2017-07-27 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (408 votes). Check out past polls.