« 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
not $txt and $el = $self->dom->at("#ctl00_ContentPlaceHolder1_UpdatePanel2 a[href*=\"Search.aspx?report=\"]")
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=\"]")
| |||||||||||||||||||||||||||||
| 42 | 0 | $txt = $el->text; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | unless ($txt) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | ($txt) = $self->content_text =~ m<\A〔新網記者 ( \p{Letter}+ (?:報導|特稿))〕\b>x; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 0 | return $txt; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | 1; | |||||||||||||||||||||||||||