Thread Parse HTML -> XML (auf Elemente einfach zugreifen) (7 answers)
Opened by Gustl at 2014-08-15 12:34

Gustl
 2014-08-16 14:17
#176872 #176872
User since
2011-01-27
441 articles
BenutzerIn
[Homepage]
user image
Ich habe es dann doch hinbekommen:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl -w

use strict;
use warnings;
use HTML::TreeBuilder::XPath;
use LWP::UserAgent;

my $url = 'www.example.de';
my $ua = LWP::UserAgent->new;
my $response = $ua->get($url);
if (not $response->is_success) {
  die "Error fetching url $url\n $response->status_line \n";
}

my $tree= HTML::TreeBuilder::XPath->new;
$tree->parse($response->decoded_content);
  
my $rezensionen = $tree->findvalue( '//div[@class="crIFrameHeaderHistogram"]/div[@class="tiny"]/b');
print $rezensionen;

my $sterne = $tree->findvalue( '//div[@class="crIFrameNumCustReviews"]/span/span/a/img/@alt');
print $sterne;
$tree->delete;


Vielen Dank und Grüße aus Kunreuth :)

View full thread Parse HTML -> XML (auf Elemente einfach zugreifen)