NewsExtractor/SiteSpecificExtractor/newnet_tw.pm

filter: Statementstmt 35.4% 11 / 31 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 25.4% 14 / 55 CC 6 SCAR 26.4
CC
6
Cov
26%
journalist
30.0
dateline
6.0
headline
2.0
CRAP 14.1
« NewsExtractor/SiteSpecificExtractor/www_mdnkids_com.pm ↑ Summary NewsExtractor/SiteSpecificExtractor/news_cts_com_tw.pm »
1 package NewsExtractor::SiteSpecificExtractor::newnet_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::GenericExtractor';
5  
6 1 ▶use Importer 'NewsExtractor::TextUtil' => qw( reformat_dateline );
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('h4 > b');
11 0 return $el->all_text;
12 }
13  
14 0 ▶sub content_text {
Subroutine content_text: not called CC=1 SCAR=6.9
Pod undocumented
15 0 my ($self) = @_;
16 0 $self->dom->find('label[for="ctl00_ContentPlaceHolder1_RadioButton6"], label[for="ctl00_ContentPlaceHolder1_RadioButton5"], label[for="ctl00_ContentPlaceHolder1_RadioButton4"], label[for="ctl00_ContentPlaceHolder1_RadioButton3"], label[for="ctl00_ContentPlaceHolder1_RadioButton2"], label[for="ctl00_ContentPlaceHolder1_RadioButton1"]')->map('remove');
17 0 return $self->SUPER::content_text();
18 }
19  
20 0 ▶sub dateline {
Subroutine dateline: not called CC=2 SCAR=17.9
Pod undocumented
21 0 my ($self) = @_;
22  
23 0 my ($dateline, $el);
24 0 ▶ if ($el = $self->dom->at('b > font[color=darkred]')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($el = $self->dom->at("b > font[color=darkred]")) 0 0 0
25 # Example: 日期:2020/7/8 下午 08:52:39
26 0 $dateline = reformat_dateline( $el->all_text(), '+08:00' );
27 }
28 0 return $dateline;
29 }
30  
31 0 ▶sub journalist {
Subroutine journalist: not called CC=5 SCAR=34.0
Pod undocumented
32 0 my ($self) = @_;
33  
34 # .col-md-8 > div:nth-child(4) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > b:nth-child(1) > font:nth-child(3)
35  
36 0 my ($txt, $el);
37  
38 0 ▶ if ($el = $self->dom->at('b > font[color=darkred]')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($el = $self->dom->at("b > font[color=darkred]")) 0 0 0
39 0 ($txt) = $el->all_text =~ m/ (?:專題|採訪): \s* (\S+) \s* 日期/x;
40 }
41 0 ▶ if ((!$txt) && ($el = $self->dom->at('#ctl00_ContentPlaceHolder1_UpdatePanel2 a[href*="Search.aspx?report="]'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $txt and $el = $self->dom->at("#ctl00_ContentPlaceHolder1_UpdatePanel2 a[href*=\"Search.aspx?report=\"]")) 0 0 0
Condition0%0/3
not $txt and $el = $self->dom->at("#ctl00_ContentPlaceHolder1_UpdatePanel2 a[href*=\"Search.aspx?report=\"]")
!ll&&!rl&&r
000
MC/DC0%0/2
not $txt and $el = $self->dom->at("#ctl00_ContentPlaceHolder1_UpdatePanel2 a[href*=\"Search.aspx?report=\"]")
not $txt $el = $self->dom->at("#ctl00_ContentPlaceHolder1_UpdatePanel2 a[href*=\"Search.aspx?report=\"]")
Truth table0%0/3
not(A) and B
A= not $txtB= $el = $self->dom->at("#ctl00_ContentPlaceHolder1_UpdatePanel2 a[href*=\"Search.aspx?report=\"]")
ABresult
0X0
100
111
42 0 $txt = $el->text;
43 }
44 0 ▶ unless ($txt) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($txt) 0 0 0
45 0 ($txt) = $self->content_text =~ m<\A〔新網記者 ( \p{Letter}+ (?:報導|特稿))〕\b>x;
46 }
47 0 return $txt;
48 }
49  
50 1 1;
« NewsExtractor/SiteSpecificExtractor/www_mdnkids_com.pm ↑ Summary NewsExtractor/SiteSpecificExtractor/news_cts_com_tw.pm »