use LWP::UserAgent; use HTML::LinkExtor; use URI::URL; my @imgs = (); $url = "http://www.sn.no/"; # for instance $ua = new LWP::UserAgent; $ua->proxy(['http', 'ftp'] => 'http://proxy'); # Make the parser. Unfortunately, we don't know the base yet (it might be diffent from $url) $p = HTML::LinkExtor->new(\&callback); # Request document and parse it as it arrives $res = HTTP::Request->new(GET => $url); $res->proxy_authorization_basic("user", "pass"); $res= $ua->request($res),sub {$p->parse($_[0])}; # Expand all image URLs to absolute ones my $base = $res->base; @imgs = map { $_ = url($_, $base)->abs; } @imgs; # Print them out print join("\n", @imgs), "\n"; # Set up a callback that collect image links sub callback { my($tag, %attr) = @_; return if $tag ne 'a href '; # we only look closer at push(@imgs, values %attr); }