Dear all,
I am trying to download a PDF file from a web page.
I have used the following code:
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;
Following is the content printed:
<html><head><title>CM/ECF LIVE - U.S. District Court - NYND</title>
<script language="javascript" src="/lib/dls_url.js"></script></head><body BGCOLOR=F9F9F9 TEXT=000000 ><div id="cmecfMainContent"><input type="hidden" id="cmecfMainContentScroll" value="0"><SCRIPT LANGUAGE="JavaScript">
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_possible=1&de_seq_num=17732 85&caseid=29430&got_receipt=1".length > 0) {
location.assign("https://ecf.nynd.uscourts.gov/doc1/12501815060?pdf_toggle_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>
However the actual page has a <iframe> tag within which the src attribute of tag has link to pdf.
id="cmecfMainContent"><input type="hidden" id="cmecfMainContentScroll" value="0">
<iframe src="/cgi-bin/show_temp.pl?file=1086820-0-.pdf&type=application/pdf" height="100%" width="100%" frameborder="0" scrolling="no">
<a href="/cgi-bin/show_temp.pl?file=1086820-0-.pdf&type=application/pdf">click here to view this file</a>
</iframe>
</body></html>
I have tried using FramesReady and mechanize, but no success. Kindly suggest how to get the pdf link.
Any help would be appreciated.
Thank you