tak_hot has asked for the wisdom of the Perl Monks concerning the following question:
Dear all,
I am trying to download a PDF file from a web page.
I have used the following code:
Following is the content printed:use WWW::Mechanize; my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->agent_alias( 'Windows IE 6' ); $mech->get("https://ecf.nynd.uscourts.gov/doc1/12501815060?pdf_toggle_ +possible=1&de_seq_num=17732 85&caseid=29430&got_receipt=1"); $mech->form_name('GetPass'); $mech->field(login => "xxx"); #Username $mech->field(key => "xxx"); #Password $mech->click(); print $mech->content;
However the actual page has a <iframe> tag within which the src attribute of tag has link to pdf.<html><head><title>CM/ECF LIVE - U.S. District Court - NYND</title> <script language="javascript" src="/lib/dls_url.js"></script></head><b +ody BGCOLOR=F9F9F9 TEXT=000000 ><div id="cmecfMainContent"><input typ +e="hidden" id="cmecfMainContentScroll" value="0"><SCRIPT LANGUAGE="Ja +vaScript"> document.cookie="PacerUser=\"li093301258064693 aDlYK1Zk9Vo\"; path=/; +domain=.uscourts.gov;"; if ("PacerPref=receipt=Y; path=/ ; domain=.uscourts.gov".length > 0) { document.cookie="PacerPref=receipt=Y; path=/ ; domain=.uscourts.gov;"; } if ("PacerClient=\"\"; path=/ ; domain=.uscourts.gov".length > 0) { document.cookie="PacerClient=\"\"; path=/ ; domain=.uscourts.gov;"; } if ("ClientDesc=\"\"; path=/ ; domain=.uscourts.gov".length > 0) { document.cookie="ClientDesc=\"\"; path=/ ; domain=.uscourts.gov;"; } if ("https://ecf.nynd.uscourts.gov/doc1/12501815060?pdf_toggle_possibl +e=1&de_seq_num=17732 85&caseid=29430&got_receipt=1".length > 0) { location.assign("https://ecf.nynd.uscourts.gov/doc1/12501815060?pdf_to +ggle_possible=1&de_seq_num=17732 85&caseid=29430&got_receipt=1"); } </SCRIPT><SCRIPT LANGUAGE="JavaScript"> var IsForm = false; var FirstField; function SetFocus() { if(IsForm) { if(FirstField) { var ind = FirstField.indexOf('document.',0); if(ind == 0) { eval(FirstField); } else { var Code = "document.forms[0]."+FirstField+".focus();"; eval(Code); } } else { var Cnt = 0; while(document.forms[0].elements[Cnt] != null) { if(document.forms[0].elements[Cnt].type != "hidden") { document.forms[0].elements[Cnt].focus(); break; } Cnt += 1; } } } return(true); } </SCRIPT> </div></body></html>
I have tried using FramesReady and mechanize, but no success. Kindly suggest how to get the pdf link.id="cmecfMainContent"><input type="hidden" id="cmecfMainContentScroll" + value="0"> <iframe src="/cgi-bin/show_temp.pl?file=1086820-0-.pdf&type=applicatio +n/pdf" height="100%" width="100%" frameborder="0" scrolling="no"> <a href="/cgi-bin/show_temp.pl?file=1086820-0-.pdf&type=application/pd +f">click here to view this file</a> </iframe> </body></html>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl iframe problem
by Anonymous Monk on Nov 13, 2009 at 01:58 UTC | |
|
Re: Perl iframe problem
by 7stud (Deacon) on Nov 13, 2009 at 03:32 UTC | |
|
Re: Perl iframe problem
by tak_hot (Initiate) on Nov 13, 2009 at 18:43 UTC |