NewsExtractor/SiteSpecificExtractor/www_bcc_com_tw.pm

filter: Statementstmt 35.4% 11 / 31 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 28.0% 14 / 50 CC 6 SCAR 20.0
CC
6
Cov
28%
journalist
12.0
content_text
12.0
dateline
6.0
CRAP 7.4
« NewsExtractor/SiteSpecificExtractor/turnnewsapp_com.pm ↑ Summary NewsExtractor/SiteSpecificExtractor/UDN.pm »
1 package NewsExtractor::SiteSpecificExtractor::www_bcc_com_tw;
2 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 extends 'NewsExtractor::SiteSpecificExtractor';
5  
6 1 ▶use Importer 'NewsExtractor::TextUtil' => 'html2text';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub headline {
Subroutine headline: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my ($self) = @_;
10 0 my $el = $self->dom->at('head > title');
11 0 return $el->all_text;
12 }
13  
14 0 ▶sub dateline {
Subroutine dateline: not called CC=2 SCAR=17.9
Pod undocumented
15 0 my ($self) = @_;
16 0 ▶ my $el = $self->dom->at('div.tt27') or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $el = $self->dom->at("div.tt27") or return undef 0 0 0
17 0 my $txt = $el->all_text;
18 0 $txt =~ s/\s+報導\z//;
19 0 return $txt;
20 }
21  
22 0 ▶sub journalist {
Subroutine journalist: not called CC=3 SCAR=24.8
Pod undocumented
23 0 my ($self) = @_;
24 0 ▶ my $content = $self->content_text or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $content = $self->content_text or return undef 0 0 0
25 0 my ($o) = $content =~ m{。 [(\(] (\p{Letter}+?) 報導 [)\)] \n\n}x;
26 0 ▶ unless ($o) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($o) 0 0 0
27 0 ($o) = $content =~ m{。 [(\(] 中廣記者 (\p{Letter}+?) [)\)] \z}x;
28 }
29 0 return $o;
30 }
31  
32 0 ▶sub content_text {
Subroutine content_text: not called CC=3 SCAR=24.8
Pod undocumented
33 0 my ($self) = @_;
34 0 my $el;
35  
36 0 for $el ($self->dom->find('script, div.ft')->each) {
37 0 $el->remove();
38 }
39  
40 0 ▶ $el = $self->dom->at('#some-class-name') or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$el = $self->dom->at("#some-class-name") or return undef 0 0 0
41 0 return html2text( $el->to_string );
42 }
43  
44 1 1;
« NewsExtractor/SiteSpecificExtractor/turnnewsapp_com.pm ↑ Summary NewsExtractor/SiteSpecificExtractor/UDN.pm »