Greetings,
Having problems finding IMG tags in an HTML that now uses LAYERs.
Didn't see anything in the LWP archives related to this.
I've been using the routine below to build a list of img urls from HTMLs but
have
now been presented with HTMLs that use a LAYER tag to load another page that
contains
the img tags I'm looking for.
Is there a silver bullet around for this situation or should I somehow parse
for LAYER tags
first to get the page I really need ?
Any assistance is appreciated.
Thanks,
Steve
$ua = new LWP::UserAgent;
@imgs = ();
sub LWPcallback {
my($tag, %attr) = @_;
return if $tag ne 'img'; # we only look closer at <img ...>
push(@imgs, values %attr);
}
# Make the parser. Don't know the base yet, might be diff from $itemurl
$LWP_p = HTML::LinkExtor->new(\&LWPcallback);
# Request document and parse it as it arrives
$res = $ua->request(HTTP::Request->new(GET => $LWP_itemurl),
sub{$LWP_p->parse($_[0])});
# Expand all image URLs to absolute ones
my $base = $res->base;
@imgs = map { $_ = url($_, $base)->abs; } @imgs;