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
| #!/usr/bin/perl -w
use strict;
use HTML::Parser 3.00 ();
open(DETAIL_SOCIETE,">detail_societe.txt") || die ("erreur de creation du fichier detail_societe.txt");
my %inside;
sub tag
{
my($tag, $num) = @_;
$inside{$tag} += $num;
print " "; # not for all tags
}
sub text
{
return if $inside{script} || $inside{style};
print $_[0];
}
my $p = HTML::Parser->new(api_version => 3,
handlers => [start => [\&tag, "tagname, '+1'"],
end => [\&tag, "tagname, '-1'"],
text => [\&text, "dtext"],
],
marked_sections => 1,
);
print DETAIL_SOCIETE $p->parse_file("2.html") || die "Can't open file: $!\n";;
close(DETAIL_SOCIETE); |
Partager