Leser: 1
|< 1 2 3 >| | 26 Einträge, 3 Seiten |
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
#!/usr/bin/perl -w
# Extract all plain text from an HTML file
use strict;
use HTML::Parser 3.00 ();
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];
}
HTML::Parser->new(api_version => 3,
         handlers   => [start => [\&tag, "tagname, '+1'"],
              Â
  end  => [\&tag, "tagname, '-1'"],
              Â
  text  => [\&text, "dtext"],
              Â
 ],
         marked_sections => 1,
    )->parse_file(shift) || die "Can't open file: $!\n";;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl -w
# Extract all plain text from an HTML file
use strict;
use HTML::Parser 3.00 ();
my $html = qq~<html><body>dies ist <b> ein test</b>.<br /><center>Test</center></body></html>~;
sub text
{
print shift;
}
HTML::Parser->new(api_version => 3, handlers => [ text => [\&text, "dtext"], ])->parse($html);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl -w
# Extract all plain text from an HTML file
use strict;
use HTML::Parser 3.00 ();
my $html = qq~<html><body>dies ist <b> ein test</b>.<br /><center>Test</center></body></html>~;
sub text
{
print shift;
}
HTML::Parser->new(api_version => 3, handlers => [ text => [\&text, "dtext"], ])->parse($html);
1
2
3
4
5
$ perl -wle'
$html = "<html><head><title>Titel</title></head><body>blubber</body></html>";
$html =~ s/<.*>//g;
print "($html)"'
()
|< 1 2 3 >| | 26 Einträge, 3 Seiten |