Hello monks, I need to get to a page that has a report I need to download. I have been struggling with this for a couple days and I need some help. Here is my code:
UPDATE: When I run
$mech->get('https://www.uspspostalone.com/fullservice/downloadAcsRepor +tSearch.html'); print $mech->status();
I get a 200. Does that mean I can successfully retrieve my file located on that page? (with mechanize filling out the form stuff etc)
#! /usr/bin/perl #needs javascript navigation capability around line 34 -date 4/17/13 use WWW::Mechanize; use LWP::UserAgent; #This block of code follows from the CAPS homepage to the Account Inqu +iries link my $mech = WWW::Mechanize->new(); my $url = "https://gateway.usps.com/bcg/login.htm"; $mech->get($url); if ($mech->success()){ print "Successful Connection\n"; } else { print "Not a successful connection\n"; } #This block of code is intended to fill in the required forms $mech->get($url); my $usr = "asdf"; #marked out for post my $pw = "asdffgg"; $mech->form_number(1); $mech->field( "login_name", $usr); $mech->form_number(2); $mech->field("user_password", $pw); $mech->click(); #follow link to dashboard $mech->follow_link( url=> 'https://prodp1.usps.com/adminweb/view.htm?r +equestPage=P1DASHBOARD'); $mech->follow_link( url=> 'https://www.uspspostalone.com/CIMweb/owner. +do?group_name=Mailer&landing=Dashboard'); print $mech->content(); #my $ua = LWP::UserAgent->new(); #my $response = $ua->get('https://prodp1.usps.com/adminweb/view.htm?re +questPage=P1DASHBOARD'); #my $response2 = $ua->get('https://www.uspspostalone.com/CIMweb/owner. +do?group_name=Mailer&landing=Dashboard'); #my $response3 = $ua->get('https://www.uspspostalone.com/CIMweb/owner. +do?group_name=Mailer&landing=MailingReports'); #my $response4 = $ua->get('https://www.uspspostalone.com/fullservice/d +ashboard.html?reset=true'); #my $response5 = $ua->get ('https://www.uspspostalone.com/fullservice/ +downloadAcsReportSearch.html'); #the last link above is the page I need to end up at. I commented this + out for now
Inspecting the page's java script has:
<script language="javascript"> function expendEvent(index) { if (document.getElementById("table"+ index).style.visible == 'hidd +en') { document.getElementById("table"+ index).style.visible = 'visib +le'; document.getElementById("image"+ index).src="images/hide_detai +ls.gif"; } else {document.getElementById("table"+ index).style.visible = 'hidden'; document.getElementById("image"+ index).src="images/show_details.g +if"; } if (document.getElementById("table"+ index).style.display == 'none +') {document.getElementById("table"+ index).style.display = 'inline'; } else { document.getElementById("table"+ index).style.display = 'none +';} } </script>
I get "link not found.." error when I run the script. Do I need to extract the tables that have the links?

In reply to Mechanizing around Javascript by PerlSufi

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.