line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::GoKGS::Scraper::TournList; |
2
|
9
|
|
|
9
|
|
1223
|
use strict; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
301
|
|
3
|
9
|
|
|
9
|
|
52
|
use warnings; |
|
9
|
|
|
|
|
34
|
|
|
9
|
|
|
|
|
228
|
|
4
|
9
|
|
|
9
|
|
61
|
use parent qw/WWW::GoKGS::Scraper/; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
52
|
|
5
|
9
|
|
|
9
|
|
510
|
use WWW::GoKGS::Scraper::Declare; |
|
9
|
|
|
|
|
34
|
|
|
9
|
|
|
|
|
76
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
1
|
54
|
sub base_uri { 'http://www.gokgs.com/tournList.jsp' } |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub __build_scraper { |
10
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
5
|
my %year_index = ( |
13
|
|
|
|
|
|
|
year => 'TEXT', |
14
|
|
|
|
|
|
|
uri => '@href', |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $tournament = scraper { |
18
|
0
|
|
|
|
|
0
|
process '.', 'name' => [ 'TEXT', sub { s/\s+\([^)]+\)$// } ], |
19
|
0
|
0
|
|
0
|
|
0
|
'notes' => [ 'TEXT', sub { m/\s+\(([^)]+)\)$/ && $1 } ]; |
|
0
|
|
|
|
|
0
|
|
20
|
0
|
|
|
|
|
0
|
process 'a', 'uri' => '@href'; |
21
|
1
|
|
|
|
|
7
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
scraper { |
24
|
0
|
|
|
0
|
|
|
process '//p[a[starts-with(@href,"tournInfo.jsp")]]', |
25
|
|
|
|
|
|
|
'tournaments[]' => $tournament; |
26
|
0
|
|
|
|
|
|
process '//a[starts-with(@href, "tournList.jsp")]', |
27
|
|
|
|
|
|
|
'year_index[]' => \%year_index; |
28
|
0
|
|
|
|
|
|
process '//p[preceding-sibling::h2/text()="Year Index"]', |
29
|
|
|
|
|
|
|
'_years' => 'TEXT'; |
30
|
1
|
|
|
|
|
10
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub scrape { |
34
|
0
|
|
|
0
|
1
|
|
my ( $self, @args ) = @_; |
35
|
0
|
|
|
|
|
|
my $result = $self->SUPER::scrape( @args ); |
36
|
0
|
|
|
|
|
|
my $year_index = $result->{year_index}; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @years = do { |
39
|
0
|
|
0
|
|
|
|
my $_years = delete $result->{_years} || q{}; |
40
|
0
|
|
|
|
|
|
$_years =~ s/ $//; |
41
|
0
|
|
|
|
|
|
split / /, $_years; |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
return $result unless @years; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
for my $i ( 0 .. @years-1 ) { |
47
|
0
|
0
|
0
|
|
|
|
next if $year_index->[$i] and $year_index->[$i]->{year} == $years[$i]; |
48
|
0
|
|
|
|
|
|
splice @$year_index, $i, 0, { year => int $years[$i] }; |
49
|
0
|
|
|
|
|
|
last; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$result; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |