#!/usr/bin/perl -w # A quick grabber script # By Alex Pounds # Copyright 2005. use strict; use LWP::UserAgent; # A quick grabber. my $ua = LWP::UserAgent->new(); $ua->agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); my $start = $ARGV[0]; my $end = $ARGV[1]; for (my $i = $start; $i <= $end; $i++) { my $j = sprintf("%03d", $i); my $link = "http://www.yourlinkgoeshere.com/whatever/$i.jpg"; my $req = HTTP::Request->new(GET => $link); my $res = $ua->request($req); if ($res->is_success) { # Got a page. print "Fetching $i.jpg... "; # Retrieve the image. if (!-f $localImg) { open(FILE, ">$localImg") or print STDERR $!; print FILE $res->content(); print " Retrieved."; close (FILE); } print "\n"; } else { if ($res->status_line !~ /404/) { print "Problem with $link: " . $res->status_line; } } # Wait a bit not to hammer the web server. if ($i != $end-1) { # Not the last image. my $wait = int(rand 3) + 1; sleep $wait; } }