« blib/lib/NewsExtractor/SiteSpecificExtractor/news_pts_org_tw.pm
↑ Summary
blib/lib/NewsExtractor/TextUtil.pm »
| 1 | package NewsExtractor::SiteSpecificExtractor::news_ebc_net_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' => 'reformat_dateline'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | sub _build_content_text { | ||||||||||
| 9 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
_build_content_text: not called CC=1 SCAR=6.9
| |||||||||||
| 10 | |||||||||||
| 11 | # Remove the in-article ad. | ||||||||||
| 12 | $self->dom->find("#contentb p > a[href^='https://bit.ly/']")->grep( | ||||||||||
| 13 | sub { | ||||||||||
| 14 | 0 | ▶ | ($_->parent->children->size == 1) | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 15 | && ($_->text =~ m/^★/) | ||||||||||
| 16 | 0 | })->map('remove'); | |||||||||
| 17 | |||||||||||
| 18 | # Remove recommendations at the end of the article body. | ||||||||||
| 19 | 0 | $self->dom->at("#contentb div.raw-style > span:nth-child(1)")->following_nodes()->map('remove'); | |||||||||
| 20 | |||||||||||
| 21 | 0 | return $self->SUPER::_build_content_text(); | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | sub journalist { | ||||||||||
| 25 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
journalist: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 26 | 0 | ▶ | my $guess = $self->dom->at('.fncnews-content > .info > span.small-gray-text') or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | my $text = $guess->all_text; | |||||||||
| 28 | 0 | my ($name) = $text =~ m/(?:東森新聞(?:\s*責任編輯)?)\s+(.+)$/; | |||||||||
| 29 | 0 | return $name; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | sub dateline { | ||||||||||
| 33 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
dateline: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 34 | 0 | ▶ | my $el = $self->dom->at(".fncnews-content > .info > span.small-gray-text") or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | return reformat_dateline($el->all_text(), '+08:00'); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 1 | 1; | |||||||||