« 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
| |||||||||||
| 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
| |||||||||||
| 25 | 0 | my ($o) = $content =~ m{。 [(\(] (\p{Letter}+?) 報導 [)\)] \n\n}x; | |||||||||
| 26 | 0 | ▶ | unless ($o) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 41 | 0 | return html2text( $el->to_string ); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||