Thread <b>*</b> mit perl aus XML filtern? (64 answers)
Opened by Hunnenkoenig at 2009-10-27 18:57

Gast wer
 2009-10-28 12:20
#127418 #127418
Ich habe den Code mal ein wenig aufgerÀumt...
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
45
46
47
48
49
50
51
52
53
#! /usr/bin/perl -w
use LWP::Simple;
use strict;

# ToDo
#print "To Do Reviews:\n";
my $currentSoftware ='321234472';
my $country ="\nCOUNTRY: United States";
my $store ='143441';

getAllReviewstest($country,$store,$currentSoftware);

sub getAllReviewstest()
{
#print $country, "\n";
print "Content-Type: text/html\n\n";
my $review=fetchReviews(@_);
print <<EOT;
<HTML>
<HEAD>
<TITLE>Reviews</TITLE>
</HEAD>
<BODY>$review</BODY>
</HTML>
EOT
}

sub getAllReviews()
{
my ($country,$store,$currentSoftware)=@_;
print $country, "\n";
print fetchReviews($store,$currentSoftware);
}

sub fetchReviews()
{
my ($store,$currentSoftware)=@_;

# my $doit = qq{curl -s -A "iTunes/4.2 (Macintosh; U; PPC Mac OS X 10.2" -H "X-Apple-Store-Front: $store-1" 'http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=$currentSoftware&mt=8' | gunzip | xmllint --format -};

# my $doit = qq{curl -s 'http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=$currentSoftware&mt=8'};
# my $riz = `$doit`;

# "get" stammt von "LWP::Simple";
my $riz=get("http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=$currentSoftware&mt=8");
my @rizray = split('\n', $riz);
# "|" bedutet "oder" in regulären Ausdrücken
@rizray = grep(!/string|key|dict|VBoxView|HBoxView|MatrixView|TextView|iTunes|LoadFrameURL|PathElement|Protocol|ScrollView|Category.*|Color|Released.*|Seller.*|Rated.*|Rate this.*|©.*|.*MB|Version.*|.*2009|Infrequent.*|NEW.*|LANGUAGES.*|REQUIREMENTS.*|Apple.*|All rights.*|Policy.*|Terms of.*|Compatible.*|Requires.*|English.*|normalStyle|GotoURL|Sort by:|by.*|Copyright|> \/<|>..</, @rizray);

my $review join('',@rizray);
$review=~s!<b>\s*\S+\s*</b>\s*-\s*-!!gs;
return $review;
}

View full thread <b>*</b> mit perl aus XML filtern?