| 1 | package NewsExtractor::SiteSpecificExtractor::www_mdnkids_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 | |||||||||||
| 6 | 1 | ▶ | use Importer 'NewsExtractor::TextUtil' => qw(reformat_dateline normalize_whitespace); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | sub dateline { | ||||||||
|
Subroutine
dateline: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 9 | 0 | my ($self) = @_; | |||||||||
| 10 | 0 | my $el = $self->dom->at('h2 ~ div.col span'); | |||||||||
| 11 | 0 | ▶ | if ($el) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 0 | my ($ymd) = $el->all_text() =~ m<\(([0-9]{4}/[0-9]{1,2}/[0-9]{1,2})\)\z>; | |||||||||
| 13 | 0 | return reformat_dateline( $ymd, '+08:00' ); | |||||||||
| 14 | } | ||||||||||
| 15 | 0 | return undef; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub journalist { | ||||||||
|
Subroutine
journalist: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 19 | 0 | my ($self) = @_; | |||||||||
| 20 | 0 | my ($x, $el); | |||||||||
| 21 | 0 | ▶ | if ($el = $self->dom->at('h2 ~ div.col span')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 0 | $x = $el->all_text() =~ s<\([0-9]{4}/[0-9]{1,2}/[0-9]{1,2}\)\z><>r; | |||||||||
| 23 | 0 | $x = normalize_whitespace($x); | |||||||||
| 24 | } | ||||||||||
| 25 | 0 | ▶ | unless ($x) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | my $t = $self->content_text; | |||||||||
| 27 | |||||||||||
| 28 | 0 | my @regexps = ( | |||||||||
| 29 | qr{\A(\S+)/\S+報導\n}, | ||||||||||
| 30 | qr{\A\S*(報導/\S+\s+攝影/\S+)\n}, | ||||||||||
| 31 | qr{\A\S*(文/\S+\s+圖/\S+)\n}, | ||||||||||
| 32 | qr{\A\S*(\S{3})\n}, | ||||||||||
| 33 | ); | ||||||||||
| 34 | |||||||||||
| 35 | 0 | for my $re (@regexps) { | |||||||||
| 36 | 0 | ($x) = $t =~ /$re/; | |||||||||
| 37 | 0 | ▶ | last if $x; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | } | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | return $x; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||