LWP get only <center> img

From: Brian Volk (BVolk_at_HPProducts.com)
Date: 12/22/04


To: "Beginners (E-mail)" <beginners@perl.org>
Date: Wed, 22 Dec 2004 12:59:53 -0500

Hi All,
 
I have a list of url source files... I need to get a certain "<img src="
from each file. The one thing that separates it from the other <img src
tags is it is preceded by <center> for example: <center><img
src="/rcp/ObjectServer?table=Images&id=381" but the sequence of img tags is
different in each of the files. Is there a way to get the img 'src' tag if
the img tag is eq to <center>? Maybe I could write a regex to do this?
pointers?
 
I've broken my script down to try and get the <center> <img scr= from just
one source file.
 
Below is one attempt where I thought I was getting close ... maybe not...
:~). Any suggestions would be greatly appreciated.
 
 
 
#!/usr/bin/perl
 
 use strict;
 use warnings;
 use HTML::TokeParser::Simple;
 use LWP::Simple;
 
 my $url = "
http://www.rcpworksmarter.com/rcp/products/detail.jsp?rcpNum=1013
<http://www.rcpworksmarter.com/rcp/products/detail.jsp?rcpNum=1013> ";
 my $page = get($url)
  or die "Could not load URL\n";
 
 my $parser = HTML::TokeParser::Simple->new(\$page)
  or die "Could not parse page";
 
 $parser->get_tag ("img") || die;
 my $token = $parser->get_token;
 if ($token->[0] eq "center");
 print;
 
# ---end ---
 
 
Brian Volk
HP Products
317.298.9950 x1245
 <mailto:bvolk@hpproducts.com> bvolk@hpproducts.com
 
 



Relevant Pages

  • Re: search robots visits or doesn`t visit this page
    ... URL in the src attribute of an IMG tag. ... I wouldn`t like to have impact on better vvvv.pl domain position in i.e. ... position in ranking for yyyy.pl domain)? ...
    (alt.html)
  • Re: error-logs() bug ??
    ... Before in the code I have got an img tag which was written like that: ... It have bad src attribute and this causes somehow my problems. ... The URL in the 'src' attribute is empty. ... So in fact requesting ...
    (comp.lang.php)
  • Re:Pub 2003 - hyperlink open in new window
    ... Code the image in the href tag with the img src ... That displays the hyperlinked image on the page. ... I am using Publisher 2003. ...
    (microsoft.public.publisher.webdesign)
  • Re: search robots visits or doesn`t visit this page
    ... I guess you are asking if search engine robots will see and follow the ... URL in the src attribute of an IMG tag. ... google ranking. ...
    (alt.html)
  • Re: [PHP] preg_match_all to match tags
    ... less than 590, to say maybe 400, this program will still resize it to ... It seems to ignore properties after the src ... img tags and a large part of the tag itself. ... PHP General Mailing List ...
    (php.general)