1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#!/usr/bin/perl
use strict; use warnings;
use HTML::Parser ();
{
my $in_object = 0;
sub start {
my ($tag, $text) = @_;
if( not $in_object ){
if( $tag eq 'object' ) {
print $text;
$in_object++;
}
} else {
print $text;
}
}
sub end {
my ($tag, $text) = @_;
if( $in_object ) {
print $text;
$in_object-- if( $tag eq 'object' );
}
}
sub text {
my $text = shift;
if( $in_object ){
print $text;
}
}
}
my $p = HTML::Parser->new( api_version => 3,
start_h => [\&start, "tagname, text"],
end_h => [\&end, "tagname, text"],
text_h => [\&text, "text"]
);
$p->parse_file( *DATA );
__DATA__
<html>
<head>
<title>test</title>
</head>
<body>
<img alt="gna gna gna" src="blabla.gif" border="0" width="60" height="60" />
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="900" height="480">
<param name="movie" value="morleycover.swf" />
<param name="quality" value="high" />
<embed src="morleycover.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="900" height="480"></embed>
</object></body></html> |
Partager