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
#!perl
use strict;
use warnings;
use WWW::Mechanize;
use Data::Dumper qw/Dumper/;
use HTML::TreeBuilder::XPath;
my $mech = WWW::Mechanize->new(
stack_depth => 0,
);
my $tree = HTML::TreeBuilder::XPath->new();
my $uri = 'http://www.perl-community.de/bat/content/view/home';
$mech->get( $uri );
my $c = $mech->content();
$tree->parse( $c );
my $chunk = $tree->findvalue( 'body//div[@class="header"]');
if( !defined($chunk) or $chunk eq "" ) {
print "no chunk @ uri: $uri\n";
print Dumper($chunk);
exit(1);
}else{
print $chunk;
}
$tree->delete();
exit(0);
† Schrift Board use strict; use warnings; Startseite Forum Blog Wiki + FAQ / IRC G‰stebuch
1 2
my ($chunk) = $tree->findnodes( 'body//div[@class="header"]'); print $chunk->toString;