« NewsExtractor/SiteSpecificExtractor/www_bcc_com_tw.pm
↑ Summary
NewsExtractor/SiteSpecificExtractor/newtalk_tw.pm »
| 1 | package NewsExtractor::SiteSpecificExtractor::UDN; | ||||||||||
| 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' => qw( html2text normalize_whitespace reformat_dateline ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | sub headline { | ||||||||
|
Subroutine
headline: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 9 | 0 | my ($self) = @_; | |||||||||
| 10 | 0 | ▶ | my $el = $self->dom->at('#story_art_title, h1.story_art_title, h1.article-content__title') or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | 0 | my $txt = $el->all_text; | |||||||||
| 12 | 0 | return normalize_whitespace($txt); | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub dateline { | ||||||||
|
Subroutine
dateline: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 16 | 0 | my ($self) = @_; | |||||||||
| 17 | 0 | my $el; | |||||||||
| 18 | 0 | ▶ | if ($el = $self->dom->at(".shareBar__info--author > span:nth-child(1), .authors time.article-content__time")) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | my $txt = $el->all_text; | |||||||||
| 20 | 0 | return normalize_whitespace($txt); | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | # opinion.udn.com | ||||||||||
| 24 | 0 | ▶ | if ($el = $self->dom->at('.story_bady_info > time[datetime]')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | return reformat_dateline($el->all_text, '+08:00'); | |||||||||
| 26 | } | ||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub journalist { | ||||||||
|
Subroutine
journalist: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 30 | 0 | my ($self) = @_; | |||||||||
| 31 | 0 | my $el; | |||||||||
| 32 | 0 | ▶ | if ($el = $self->dom->at(".shareBar__info--author, .authors span.article-content__author")) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | my $txt = $el->all_text; | |||||||||
| 34 | 0 | $txt =~ s/\s+/ /g; # Sometimes there are newlines | |||||||||
| 35 | 0 | return normalize_whitespace($txt); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | # opinion.udn.com | ||||||||||
| 39 | 0 | ▶ | if ($el = $self->dom->at('.story_bady_info')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | ▶ | return $el->find('a.author')->map(sub { normalize_whitespace( $_->text ) })->join(', ') . ""; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 41 | } | ||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | sub content_text { | ||||||||
|
Subroutine
content_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 0 | my ($self) = @_; | |||||||||
| 46 | 0 | my $el = $self->dom->at("section.article-content__editor"); | |||||||||
| 47 | 0 | $el->find("script, style")->map("remove"); | |||||||||
| 48 | 0 | return html2text("$el"); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | 1; | |||||||||