line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::MobileCarrierJP::Softbank::PictogramInfo; |
2
|
1
|
|
|
1
|
|
382
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
4
|
1
|
|
|
1
|
|
3
|
use WWW::MobileCarrierJP::Declare; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
3
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my @urls = map { sprintf 'http://creation.mb.softbank.jp/web/web_pic_%02d.html', $_ } 1..6; |
8
|
0
|
|
|
0
|
0
|
|
sub url { [@urls] } |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub scrape { |
11
|
0
|
|
|
0
|
0
|
|
my $xpath = q{//div[@class='contents']/table[2]/tr[1]/td/table/tr/td/table/tr[count(preceding-sibling::tr)>0]}; |
12
|
|
|
|
|
|
|
my $scraper = scraper { |
13
|
0
|
|
|
0
|
|
|
col 2, unicode => [ 'TEXT', sub { s/\s//g } ]; |
|
0
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
}; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my @res = (); |
17
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(agent => __PACKAGE__); |
18
|
0
|
|
|
|
|
|
for my $url ( @urls ) { |
19
|
0
|
|
|
|
|
|
my $res = $ua->get($url); |
20
|
0
|
0
|
|
|
|
|
$res->is_success or die "cannot get $url"; |
21
|
0
|
|
|
|
|
|
my $html = $res->content; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$html =~ s//ESC/g; # workaround for XML::LIbXML parser |
24
|
0
|
|
|
|
|
|
$html =~ s//SI/g; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $result = scraper { |
27
|
0
|
|
|
0
|
|
|
process $xpath, 'rows[]', $scraper; |
28
|
0
|
|
|
|
|
|
}->scrape( $html )->{rows}; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
push @res, @$result; |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
|
|
|
return \@res; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
__END__ |