PerlSufi has asked for the wisdom of the Perl Monks concerning the following question:
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
UPDATE: When I run
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)$mech->get('https://www.uspspostalone.com/fullservice/downloadAcsRepor +tSearch.html'); print $mech->status();
Inspecting the page's java script has:#! /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
I get "link not found.." error when I run the script. Do I need to extract the tables that have the links?<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>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Mechanizing around Javascript
by runrig (Abbot) on Apr 25, 2013 at 22:26 UTC | |
Re: Mechanizing around Javascript
by Gangabass (Vicar) on Apr 26, 2013 at 12:26 UTC | |
by PerlSufi (Friar) on Apr 26, 2013 at 14:21 UTC | |
by Gangabass (Vicar) on Apr 26, 2013 at 14:56 UTC | |
by PerlSufi (Friar) on Apr 26, 2013 at 15:30 UTC | |
by Gangabass (Vicar) on Apr 27, 2013 at 02:13 UTC |
Back to
Seekers of Perl Wisdom