Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: submitting nameless form using WWW::mechanize

by b10m (Vicar)
on Jun 18, 2008 at 07:37 UTC ( #692647=note: print w/ replies, xml ) Need Help??


in reply to Re^2: submitting nameless form using WWW::mechanize
in thread submitting nameless form using WWW::mechanize

"i have checked for form number using $mech->forms() which displays nothing."

This might be due to JavaScript generated forms, which are really a pain in the ***. Try to look at the source through your preferred webbrowser and see what's going on there. If the form is there, without a name, indeed simply count them (and don't forget hidden forms ;-)

--
b10m


Comment on Re: submitting nameless form using WWW::mechanize
Re^2: submitting nameless form using WWW::mechanize
by opensourcer (Monk) on Jun 19, 2008 at 02:06 UTC
    The following is the code inside the html.
    <body onLoad="getSearch();getUserSettings();callonLoad();"> <form> <p>&nbsp;</p> <table width="775" border="0" align="center" cellpadding="0" cellsp +acing="0" bgcolor="#FFFFFF"> <tr> <td><img src="/userportal/pages/usermedia/inventumtest.1/images/ +top.jpg" width="775" height="111"></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding= +"0"> <tr> <td width="33%"><div align="center"><img src="/userportal/ +pages/usermedia/inventumtest.1/images/lady.jpg" width="161" height="2 +00"></div></td> <td><table width="240" height="150" border="0" align="cen +ter" cellpadding="0" cellspacing="0" background="/userportal/pages/us +ermedia/inventumtest.1/images/TableBG.jpg"> <tr> <td valign="top"><table width="100%" height="100%" bo +rder="0" cellpadding="1" cellspacing="1"> <tr> <td colspan="2" class="loginBoxMainStyle"><div a +lign="left">&nbsp;Login</div></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="right" +>Service Type :</div></td> <td> <select name="type" class="loginBoxTextStyl +e"><option value="1">Check Account Details</option></select> </td> </tr> <tr> <td class="loginBoxTextStyle"><div align="right" +>Login ID : </div></td> <td><input type="text" name="username" value="" +class="loginBoxFormTextStyle"></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="right" +>Password : </div></td> <td><input type="password" name="password" value +="" class="loginBoxFormTextStyle"></td> </tr> <tr> <td colspan="2" class="loginBoxTextStyle"><div a +lign="center"> <input type="checkbox" id="rememberme" name="rememberme" >Remember Me +</div></td> </tr> <tr> <td colspan="2"><div align="center"> <input type="button" value="Login" class="loginBoxTextStyle" onclick=" +return savesettings();"/> </div></td> </tr> </table></td> </tr> </table></td> <td width="33%"><table width="100%" border="0" cellspacin +g="0" cellpadding="0"> <tr id="popup" style="display:none"> <td><table width="240" height="150" border="0" align= +"center" cellpadding="0" cellspacing="0" background="/userportal/page +s/usermedia/inventumtest.1/images/TableBG.jpg"> <tr> <td valign="top"><table width="100%" height="100%" + border="0" cellpadding="1" cellspacing="1"> <tr> <td colspan="2" class="loginBoxMainStyle"><d +iv align="left">&nbsp;Session Details </div></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="ri +ght">Start Time : </div></td> <td><INPUT TYPE=TEXT NAME="start" SIZE=17 va +lue="18/06/2008 09:24:55" readonly></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="ri +ght">Duration : </div></td> <td><INPUT TYPE=TEXT NAME="duration" SIZE=17 + readonly></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="ri +ght">Balance :</div></td> <td><INPUT TYPE=TEXT size="17" NAME="subs" v +alue="" readonly></td> </tr> <tr> <td class="loginBoxTextStyle" colspan="2"> <b>Your Internet Session Active</b> &nbsp;&nbsp;<a href="/userportal/logout.do"> +Click Here To Logout</a></td> </tr> <tr> <td class="loginBoxTextStyle"><div align="ri +ght"></div></td> <td>&nbsp;</td> </tr> </table></td> </tr> </table></td> </tr> </table> </td> </tr> </table></td> </tr> <tr> <td><img src="/userportal/pages/usermedia/inventumtest.1/images/ +inventlogo.png" width="140" height="43"></td> </tr> <tr> <td bgcolor="#336699"><div align="center" class="loginBoxTextSty +le"><font color="#ffffff">Powered by SSG Unify <a href="http://www.in +ventum.cc"><font color="#ffffcc"> (c) Inventum Technologies Pvt. Ltd. +</font></a></font></div></td> </tr> </table> <INPUT TYPE=hidden NAME="clock"> </form>

    I have tried every number in the block (1..x) but ...
    script says: There is no form numbered 4 at autologin.pl line 45 Died at /usr/lib/perl5/site_perl/5.8.8/WWW/Mechanize.pm line 1724.
      There is no action for the <form> that you're showing us (without which it can't "do" anything, nor does <input type="button" value="Login" class="loginBoxTextStyle" onclick="return savesettings();"/> clarify much other than to make it clear you're dealing with a js function.

      Is it possible that the page is broken (even when visited with your browser), or that you missed something in the .html?

      Update: "can't" above is badly stated; even without an action, use of <form> and subordinate elements will effect rendering. But worse, even though the OP's code update made it clear (duh! even to me!) that the issue was at least in part a js issue, I didn't consider that in the flat "can't." Bah! And apologies for careless thought.

      However, parv's question below about the default action (when none is specified) sent me checking the w3c's html 4.01 specification. I may still have missed something, and, as always, it's well to remember that browser-writers sometimes :-) build browsers that are not fully conformant.

      Nonetheless, what follows is what I found:

      <!ATTLIST FORM
      • %attrs;               -- %coreattrs, %i18n, %events --
      • action %URI; #REQUIRED -- server-side form handler --
      • ...
      • onsubmit %Script; #IMPLIED -- the form was submitted --

      ....

      action = uri CT
        This attribute specifies a form processing agent. User agent behavior for a value other than an HTTP URI is undefined.

        Missing an explicit "action", does the "action" not default to the current URL?
        it's ISP page to for login to active the internet session.
        the extension of page is something like ".do" e.g: http://xxxx/xxx/xx.do.
        I'm writing a script so that i can login to page whenever i get disconnected.
      I found only one instance of "<form"; so form(1) /should/ have worked.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-07-26 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls