Scraper/Plugin/ViewBBS.pm

filter: Statementstmt 26.9% 14 / 52 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 44.4% 4 / 9 Podpod 100% 1 / 1 totaltotal 26.0% 19 / 73 CC 6 SCAR 29.4
CC
6
Cov
23%
scrape
42.0
__ANON__
2.0
__ANON__
2.0
CRAP 18.9
« Scraper/Plugin/ListDiary.pm ↑ Summary Scraper/Utils.pm »
1 package WWW::Mixi::Scraper::Plugin::ViewBBS;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use WWW::Mixi::Scraper::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use WWW::Mixi::Scraper::Utils qw( _datetime _uri );
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 1 validator {qw(
9 id is_number
10 comm_id is_number
11 comment_count is_number
12 page is_number_or_all
13 )};
14
15 0 ▶sub scrape {
Subroutine scrape: not called CC=6 SCAR=37.4
Pod documented
16 0 my ($self, $html) = @_;
17
18 0 my %scraper;
19 0 ▶ $scraper{images} = scraper {
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 0 process 'a',
21 link => '@onClick';
22 0 process 'a>img',
23 thumb_link => '@src';
24 0 result qw( link thumb_link );
25 0 };
26
27 0 ▶ $scraper{topic} = scraper {
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 process 'dl[class="bbsList01 bbsDetail"]>dt>span.date',
29 time => 'TEXT';
30 0 process 'dl[class="bbsList01 bbsDetail"]>dt>span.titleSpan',
31 subject => 'TEXT';
32 0 process 'dd.bbsContent>dl>dt>a',
33 name => 'TEXT',
34 name_link => '@href';
35 0 process 'dd.bbsContent>dl>dd',
36 description => $self->html_or_text;
37 process 'dd.bbsContent>dl>dd>div.communityPhoto>table>tr>td',
38 0 'images[]' => $scraper{images};
39 0 result qw( time subject description name name_link images link );
40 0 };
41
42 # bbs topic is not an array
43 0 my $stash = $self->post_process($scraper{topic}->scrape(\$html))->[0];
44
45 # XXX: this fails when you test with local files.
46 # However, this link cannot be extracted from the html,
47 # at least as of writing this. ugh.
48 0 $stash->{link} = $self->{uri};
49
50 0 ▶ $scraper{comments} = scraper {
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 0 process 'dt>a',
52 link => '@href',
53 name => 'TEXT';
54 0 process 'dd',
55 description => $self->html_or_text;
56 0 result qw( link name description );
57 0 };
58
59 0 ▶ $scraper{list} = scraper {
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 process 'dl.commentList01>dt[class="commentDate clearfix"]>span.date',
61 'times[]' => 'TEXT';
62 0 process 'dl.commentList01>dt[class="commentDate clearfix"]>span.senderId',
63 'sender_ids[]' => 'TEXT';
64 process 'dl.commentList01>dd>dl.commentContent01',
65 0 'comments[]' => $scraper{comments};
66 0 result qw( times sender_ids comments );
67 0 };
68
69 0 my $stash_c = $self->post_process($scraper{list}->scrape(\$html))->[0];
70
71 0 ▶ my @comments = @{ $stash_c->{comments} || [] };
Condition0%0/2
$stash_c->{'comments'} || []
l!l
00
MC/DC0%0/1
$stash_c->{'comments'} || []
$stash_c->{'comments'}
Truth table0%0/2
A
A= $stash_c->{'comments'}
Aresult
11
00
72 0 ▶ my @times = @{ $stash_c->{times} || [] };
Condition0%0/2
$stash_c->{'times'} || []
l!l
00
MC/DC0%0/1
$stash_c->{'times'} || []
$stash_c->{'times'}
Truth table0%0/2
A
A= $stash_c->{'times'}
Aresult
11
00
73 0 ▶ my @sender_ids = @{ $stash_c->{sender_ids} || [] };
Condition0%0/2
$stash_c->{'sender_ids'} || []
l!l
00
MC/DC0%0/1
$stash_c->{'sender_ids'} || []
$stash_c->{'sender_ids'}
Truth table0%0/2
A
A= $stash_c->{'sender_ids'}
Aresult
11
00
74 0 foreach my $comment ( @comments ) {
75 0 $comment->{time} = _datetime( shift @times );
76 0 $comment->{subject} = shift @sender_ids;
77
78 # incompatible with WWW::Mixi to let comment links
79 # look more 'permanent' to make plagger/rss readers happier
80 0 $comment->{name_link} = _uri( $comment->{link} );
81 $comment->{link} = $stash->{link}
82 ? _uri( $stash->{link} . '#' . $comment->{subject} )
83 0 ▶ : undef;
Branch: 1 branch
BranchTrueFalseTotal
$stash->{'link'} ? : 0 0 0
84 }
85 0 $stash->{comments} = \@comments;
86
87 0 return $stash;
88 }
89
90 1 1;
91
92 __END__
« Scraper/Plugin/ListDiary.pm ↑ Summary Scraper/Utils.pm »