lib/Novel/Robot/Parser/kanunu8.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 44 CC 1 SCAR 6.9
CC
1
Cov
0%
parse_board
2.0
parse_board_item
2.0
BEGIN
2.0
CRAP 2.0
1 # ABSTRACT: http://www.kanunu8.com
2 package Novel::Robot::Parser::kanunu8;
3 use strict;
4 use warnings;
5 use utf8;
6  
7 use base 'Novel::Robot::Parser';
8 use Web::Scraper;
9  
10 sub parse_board {
11 my ( $self, $html_ref ) = @_;
12  
13 my $parse_writer = scraper {
14 process_first '//h2/b', writer => 'TEXT';
15 };
16  
17 my $ref = $parse_writer->scrape( $html_ref );
18  
19 $ref->{writer} =~ s/作品集//;
20 return $ref->{writer};
21 }
22  
23 sub parse_board_item {
24 my ( $self, $html_ref ) = @_;
25  
26 my $parse_writer = scraper {
27 process '//tr//td//a',
28 'booklist[]' => {
29 url => '@href',
30 book => 'TEXT'
31 };
32 };
33  
34 my $ref = $parse_writer->scrape( $html_ref );
35  
36 my @books =
37 grep { $_->{url} and ( $_->{url} =~ /index.html$/ or $_->{url} =~ m#/\d+/$# ) } @{ $ref->{booklist} };
38 return \@books;
39  
40 } ## end sub parse_board_item
41  
42 1;