develooper Front page | perl.libwww | Postings from December 2001

parsing HTML's with LAYER tag

From:
steve borruso
Date:
December 16, 2001 08:50
Subject:
parsing HTML's with LAYER tag
Message ID:
000201c18651$59969bc0$6501a8c0@stny.rr.com

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;




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About