Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi monks, I have tried to automate the browsing method using WWW::Mechanize module as below:

use strict; use Data::Dumper; use WWW::Mechanize; use POSIX qw(strftime); my $currSysDate =strftime ("%b".'&year='."%y", localtime); # DAY Langu +age my $mech = WWW::Mechanize->new(autocheck => 1); my $url = "http://www.somenet.com/login.aspx"; my $user = 'user'; my $pass = 'pass'; $mech->get( $url ); if ($mech->success()) { $mech->submit_form( form_name => 'Form1', fields => { txtUsername => $user, txtPassword => $pass, }, button => 'Button3', ); $mech->get("http://www.somenet.com/showCardEmpMonthlyReport.aspx? +month=$currSysDate&Reptype=&empcode=$user"); my $str = $mech->content(); print $str; }

I am getting error as:

Error GETing javascript:__doPostBack('EmpSideMenu1$lnkAttendance',''): + Protocol scheme 'javascript' is not supported at array.pl line 10047

Source of particular URL is:

<TD class="sidemenu" style="BACKGROUND-IMAGE: url(Images1\MenuBg.jpg); + BACKGROUND-REPEAT: repeat-x">&nbsp;&nbsp;&nbsp; <a id="EmpSideMenu1_lnkAttendance" href="javascript:__doPostBack('EmpS +ideMenu1$lnkAttendance','')" style="color:White;width:160px;">Attenda +nce Report</a></TD> <script language="javascript"> <!-- function __doPostBack(eventTarget, eventArgument) { var theform; if (window.navigator.appName.toLowerCase().indexOf("netscape") + > -1) { theform = document.forms["Form1"]; } else { theform = document.Form1; } theform.__EVENTTARGET.value = eventTarget.split("$").join(":") +; theform.__EVENTARGUMENT.value = eventArgument; theform.submit(); } // --> </script>

From chatterbox, I came to know WWW::Mechanize doesn't support Javascript. Based on Corion suggestion I have used Win32::IE::Mechanize module. Eventhen javascript hyper-link is not working in follow_link.

use strict; use Data::Dumper; use Win32::IE::Mechanize; my $ie = Win32::IE::Mechanize->new( visible => 1 ); my $url = "http://www.somenet.com/login.aspx"; my $user = 'user'; my $pass = 'pass'; $ie->get( $url ); if ($ie->success()) { $ie->submit_form( form_name => 'Form1', fields => { txtUsername => $user, txtPassword => $pass, }, button => 'Button3', ); $ie->follow_link( text_regex => qr/Attendance Report/i ); #Not wo +rking $ie->submit_form( form_name => 'Form1', button => 'Button1', ); print $ie->content(); } __END__ Some time Error as: Can't locate object method "warn" via package "sssself" (perhaps you f +orgot to load "sssself"?) at C:/Perl/site/lib/Win32/IE/Mechanize.pm l +ine 971.

How to follow up the javascript hyper-link? Please help me. Thanks in advance.

Updated I have updated sssself->warn( "No inputcontrol by the name '$fname'" ); as $self->warn( "No inputcontrol by the name '$fname'" ); in Win32::IE::Mechanize. Still not working.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';


In reply to Follow-up Javascript Hyperlink by Samy_rio

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-20 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found