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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.