Created
November 17, 2012 18:29
-
-
Save mark-cooper/4098574 to your computer and use it in GitHub Desktop.
Download PragPub magazine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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