« NewsExtractor/SiteSpecificExtractor/www_xinhuanet_com.pm
↑ Summary
NewsExtractor/SiteSpecificExtractor/m_news_cctv_com.pm »
| 1 | package NewsExtractor::SiteSpecificExtractor::www_ntdtv_com; | ||||||||||
| 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 | 1 | ▶ | use Importer 'NewsExtractor::TextUtil' => qw( normalize_whitespace ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 0 | ▶ | sub content_text { | ||||||||
|
Subroutine
content_text: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 8 | 0 | my ($self) = @_; | |||||||||
| 9 | 0 | my $el = $self->dom->at("div[itemprop=articleBody]"); | |||||||||
| 10 | 0 | $el->find("div.print_link, div.single_ad")->map("remove"); | |||||||||
| 11 | 0 | my $last_child = $el->children->last; | |||||||||
| 12 | 0 | ▶ | if ($last_child->all_text =~ /相關鏈接:/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 0 | $last_child->remove; | |||||||||
| 14 | } | ||||||||||
| 15 | 0 | my $txt = $el->all_text; | |||||||||
| 16 | 0 | $txt = normalize_whitespace($txt); | |||||||||
| 17 | 0 | return $txt; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub journalist { | ||||||||
|
Subroutine
journalist: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 21 | 0 | my ($self) = @_; | |||||||||
| 22 | 0 | my ($name) = $self->content_text =~ m{ | |||||||||
| 23 | \n | ||||||||||
| 24 | ( | ||||||||||
| 25 | 新唐人亞太電視\p{Letter}+?報導 | ||||||||||
| 26 | | ( 新唐人記者[\p{Letter}、]+報導 ) | ||||||||||
| 27 | | ( 新唐人\p{Letter}+記者站綜合報導 ) | ||||||||||
| 28 | | (\s* 記者\p{Letter}+報導/責任編輯:\p{Letter}+ \s*) | ||||||||||
| 29 | | (\s* 責任編輯:\p{Letter}+ \s*) | ||||||||||
| 30 | | (轉自\p{Letter}+/責任編輯:\p{Letter}+ \s*) | ||||||||||
| 31 | | ( 採訪/\p{Letter}+ \s+ 編輯/\p{Letter}+ \s+ 後製/\p{Letter}+ ) | ||||||||||
| 32 | ) | ||||||||||
| 33 | \z}xs; | ||||||||||
| 34 | |||||||||||
| 35 | 0 | $name =~ s/\A(//; | |||||||||
| 36 | 0 | $name =~ s/)\z//; | |||||||||
| 37 | |||||||||||
| 38 | 0 | return $name; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | 1; | |||||||||