in reply to Image grabber remotely hosted

Yes, you would grab the original page (using one of the LWP modules) and then parse the file using HTML::LinkExtor to find the image links and send off a separate request for each link found.

--
<http://www.dave.org.uk>

European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/>

Replies are listed 'Best First'.
RE: Re: Image grabber remotely hosted
by damian (Beadle) on Sep 04, 2000 at 10:34 UTC
    hi davorg, you mean i will be able to download even the images and save it on my server? thanks.

      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.

      --
      <http://www.dave.org.uk>

      European Perl Conference - Sept 22/24 2000, ICA, London
      <http://www.yapc.org/Europe/>