Thread suche erst ab einem bestimmten bereich aktivieren (51 answers)
Opened by Rocco at 2006-06-23 16:05

renee
 2006-06-23 18:12
#8113 #8113
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Ich würde das mit CPAN:HTML::Parser machen:

Code: (dl )
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
#!/usr/bin/perl

use strict;
use warnings;
use HTML::Parser;

my $html_file = './test.html';
my @search = qw(Hallo Welt test);
my $string = "";

my $parser = HTML::Parser->new(
api_version => 3,
start_h => [\&start,"self,tagname,attr"],
text_h => [\&text,"self,dtext"],
end_h => [\&end,"self,tagname"]);

print "parse...";
$parser->parse_file($html_file);
print "done\n";
for my $word(@search){
if($string =~ /$word/){
print $word," gefunden\n";
}
}


sub start{
my ($self,$tag,$attr) = @_;
if($tag eq 'div' && $attr->{class} eq 'scroll'){
$self->{search} = 1;
}
}

sub text{
my ($self,$dtext) = @_;
$string .= $dtext if($self->{search});
}

sub end{
my ($self,$tag) = @_;
if($tag eq 'div'){
$self->{search} = 0;
}
}
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread suche erst ab einem bestimmten bereich aktivieren