cafaro has asked for the wisdom of the Perl Monks concerning the following question:
The Perl modules that I use:http://www.site.com/images/?id=345435
The actual Perl code I use for downloading the images:WWW::Mechanize; # to browse through the site LWP::UserAgent; # for downloading the images
I hope I gave enough information. Cheers, cafaro# load modules WWW::Mechanize; LWP::UserAgent; # create new sessions $mechanize = WWW::Mechanize->new(autocheck => 1); # "autocheck => +1" will show possible errors $useragent = LWP::UserAgent->new; # define useragent $agent = "Mozilla/5.0"; $mechanize->agent($useragent); $useragent->agent($agent); # define the url $mechanize->get("http://www.site.com/images/"); # fetch the content $content = $mechanize->content(); # get the image url by parsing the content with regular expression +s $content =~ /<tr><td><img src="(.+)" alt="php-image" \/><\/td><\/t +r>/; # the url will be extracted to $1 # download the image $time = time(); $useragent->mirror($1, "/home/cafaro/images/$time.jpg"); # provide output print "The image ($time.jpg) has been saved.\n";
|
|---|