yantar has asked for the wisdom of the Perl Monks concerning the following question:
I am working on generating a report for a customer. I can get this report from a web page i can access.
First i will need to fill a form with my user name, password and choose a server from a drop down list, and log in.
Second i need to click a link for the report section.
Third a need to fill a form to create the report.
I found that its hard for me to debug what i do since i cant see the webpage i currently hold in $mech and verify i am on the right place.
Second, i am not sure i read the source code correctly to find the field names etc.
Here is what i wrote so far:
my $mech = WWW::Mechanize->new(); my $url = 'http://xxx; $mech->get( $url ); $mech->submit_form( form_number => 1, fields => { Username => 'someone', Password => 'pass', Server => 'Live' }, ); die unless ($mech->success);
The source code is:
<!-- login panel begin --> <div id="ctl00_ctl00_cphserver_cphLogin_pnlLogin" class="leftpanel" st +yle="Visibility:visible;Display:block;"> <span style="display:inline-block;width:120px;">Username</span> <br \> <input name="ctl00$ctl00$cphserver$cphLogin$txtUser" type="text" id="c +tl00_ctl00_cphserver_cphLogin_txtUser" onKeyPress="javascript: return + txtUser_onKeyPress();" style="color:Navy;width:140px;" /> <br \> <span style="display:inline-block;width:120px;">Password</span> <br \> <input name="ctl00$ctl00$cphserver$cphLogin$txtPW" type="password" id= +"ctl00_ctl00_cphserver_cphLogin_txtPW" onKeyPress="javascript: return + txtPW_onKeyPress();" style="color:Navy;width:140px;" /> <br \> <span style="display:inline-block;width:120px;">Server</span> <br \> <select name="ctl00$ctl00$cphserver$cphLogin$ddlServers" id="ctl00_ctl +00_cphserver_cphLogin_ddlServers" style="color:Navy;width:140px;"> <option value="Live">Live</option> <option selected="selected" value="Test">Test</option> </select> <br \> <br \> <input type="submit" name="ctl00$ctl00$cphserver$cphLogin$btnSignIn" v +alue="Sign-In" id="ctl00_ctl00_cphserver_cphLogin_btnSignIn" /> <br /> <br /> </div> <!-- login panel end -->
Please help me the understand how to debug easily and how to read the source code so i can program correctly.
Thank you! Yaniv
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using and debuging www Mechanize
by Corion (Patriarch) on Jun 08, 2009 at 12:32 UTC | |
by yantar (Initiate) on Jun 08, 2009 at 12:51 UTC | |
by Corion (Patriarch) on Jun 08, 2009 at 12:58 UTC | |
by yantar (Initiate) on Jun 08, 2009 at 13:14 UTC | |
by Anonymous Monk on Jun 08, 2009 at 13:22 UTC | |
| |
|
Re: using and debuging www Mechanize
by lakshmananindia (Chaplain) on Jun 08, 2009 at 12:34 UTC | |
by Anonymous Monk on Jun 08, 2009 at 12:45 UTC | |
|
Re: using and debuging www Mechanize
by Anonymous Monk on Jun 08, 2009 at 12:56 UTC |