1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/usr/bin/perl
use strict;
use LWP::Simple;
use File::Basename;
use Digest::MD5 qw(md5_hex);
use Perl6::Say;
my $uri = shift or die "uri please!. ";
my $content = get($uri);
my @l = $content =~ m{<a.*?href="?(http://[^ ]+?\.jpe?g)"?}gi;# 苦肉の策
# my @l = $content =~ m{<a.*?href="(http://[^"]+\.jpe?g)"}gi;# オリジナル
my $dir = md5_hex($uri);
mkdir $dir or die unless -d $dir;
say "make dir > " . $dir;
foreach (@l) {
my $filename = basename($_);
mirror($_, sprintf("%s/%s", $dir, $filename));
say "save image > " . $filename;
sleep 1;
};
open my $fh, ">", "$dir/uri.txt" or die;
print $fh $uri;
close $fh;
|