in reply to RE: Re: Image grabber remotely hosted
in thread Image grabber remotely hosted
Yep. It would be something like this (untested code):
use strict; use LWP::Simple; use HTML::LinkExtor; my $url = 'http://www.example.com/index.html'; my $file = 'index.html'; getstore($url, $file); my $p = HTML::LinkExtor->new; $p->parse_file($file); my $i = '000'; while ($p->links) { next unless $_->[0] = 'img'; shift @$_; my %attrs = @$_; getstore($attrs{src}, "img$i"; ++$i; }
Actually, thinking about it, that's not quite right as the image URLs that you'll get back in $attrs{src} will be relative to the main page so you might need to munge them a bit to get the absolute URL. Also by parsing the URL you could probably get a better image filename than the 'img00X' names that I'm using.
--
|
|---|