There's a batch of really gorgeous images released under the Creative Commons license at http://draves.org/pix/kdn/; the following code fetches all of them (slowly) at their maximum resolution.
Max resolution is big - 2 to 8 MB each. These are seriously detailed pictures. I added a 5-minute pause between fetches to be polite.
my $current = $base;
$mech->get($current);
while (1) {
my ($image) = (($mech->content) =~ /img .* src="([^"]+)/s);
$image=~ s/ /%20/g;
$image_mech->get("http://draves.org/pix/$image");
print $image,"\n";
my ($dir,$name) = ($image =~ m{^(.*/)(.*)$});
system "mkdir -p $dir";
open PIX, ">$image" or die "Can't open $image: $!";
print PIX $image_mech->content;
close PIX;
sleep 300;
$mech->follow_link('text'=>'next');
last unless $mech->success;
}
Strictly utilitarian, but it gets the job done, and lets me have truly bizarro desktop graphics, thich is nice. I'm realizing that the 'next' link will probably crap out when it gets to the last page, but that's not a big deal since I want to stop at that point anyway.
Re:Mech images
pemungkah on 2005-03-24T16:49:10
Yes, I thought it should, but I didn't see it in the Mech object's images array while debugging the script, so I just went ahead and extracted it myself.
Have I exposed a bug?Re:Mech images
petdance on 2005-03-24T17:55:11
hmmm, maybe. Or maybe we havne't finished that part yet.