Skip to content

Instantly share code, notes, and snippets.

@mark-cooper
Created November 17, 2012 18:29
Show Gist options
  • Save mark-cooper/4098574 to your computer and use it in GitHub Desktop.
Save mark-cooper/4098574 to your computer and use it in GitHub Desktop.
Download PragPub magazine
use URI;
use URI::URL;
use Web::Scraper;
use LWP::Simple;
my $pp = "http://pragprog.com/magazines";
my $ok = "epub";
my $mags = scraper {
process "span.link", "mags[]" => scraper {
process "a", link => '@href';
};
};
my $res = $mags->scrape(URI->new($pp));
for my $mag (@{$res->{mags}}) {
my $url = $mag->{link};
my @parts = (new URI::URL $url)->path_components;
my $file = $parts[3];
if ( ! -e $file && $file =~ /$ok/ ) {
print "SAVING FILE:\t$file\n";
getstore($url, $file);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment