Skip to content

Instantly share code, notes, and snippets.

@vincentchu
Created August 11, 2009 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentchu/165516 to your computer and use it in GitHub Desktop.
Save vincentchu/165516 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
$cookie="cookies.txt";
$rackNum = 16;
$docID = 84699;
$pgStart = 262;
$pgEnd = 291;
$header = "maggiore-qft-new-";
$sleepTime = 300;
for ($i=$pgStart; $i<=$pgEnd; $i++) {
$url = "http://www.myilibrary.com/content/rack_$rackNum/$docID/$i.asp";
$buffer = sprintf("foo_%03d", $i);
$buffer2 = sprintf("bar_%03d", $i);
$cmdStr = "wget --output-document=$buffer --load-cookies=$cookie $url";
$outPDF = sprintf("%s--%04d.pdf", $header, $i);
print "$cmdStr - $outPDF\n";
system($cmdStr);
system("grep -P -o '\\w+\\.pdf' $buffer > $buffer2");
open FOO, "$buffer2";
$pdf = <FOO>; chomp $pdf;
close FOO;
$pdfURL = "http://www.myilibrary.com/content/rack_$rackNum/$docID/$pdf";
system("wget --output-document=$outPDF --load-cookies=$cookie $pdfURL");
sleep $sleepTime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment