in reply to Image Size in an HTML file
This snippet will extract the src attributes any img tags that are found:
From here you can add code to open the image file, and for the fun part, insert the new value in . . .use strict; use IO::File; use HTML::Parser; # version 3.15, by the way # get the contents of the HTML file my $fh = new IO::File('google.html'); my $html = do {local $/; <$fh>}; my $parser = HTML::Parser->new(api_version => 3); $parser->handler(start => \&start, 'self,tagname,attr'); $parser->parse($html); sub start { my ($parser,$tag,$attr) = @_; return unless $tag eq 'img'; # insert code to process the image file print $attr->{src}, "\n"; }
Jeff
R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Image Size in an HTML file
by Stamp_Guy (Monk) on Jun 02, 2001 at 20:25 UTC |