in reply to Re: Image grabber remotely hosted
in thread Image grabber remotely hosted

hi davorg, you mean i will be able to download even the images and save it on my server? thanks.

Replies are listed 'Best First'.
RE: RE: Re: Image grabber remotely hosted
by davorg (Chancellor) on Sep 04, 2000 at 10:48 UTC

    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/>