line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use utf8; |
2
|
1
|
|
|
1
|
|
6
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
3
|
1
|
|
|
1
|
|
26
|
extends 'NewsExtractor::SiteSpecificExtractor'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Importer 'NewsExtractor::TextUtil' => qw< html2text normalize_whitespace >; |
6
|
1
|
|
|
1
|
|
268
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
my ($self) = @_; |
8
|
|
|
|
|
|
|
if (my $el = $self->dom->at('h1[itemprop="headline"]')) { |
9
|
0
|
|
|
0
|
0
|
|
return $el->all_text; |
10
|
0
|
0
|
|
|
|
|
} |
11
|
0
|
|
|
|
|
|
return undef; |
12
|
|
|
|
|
|
|
} |
13
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my ($self) = @_; |
15
|
|
|
|
|
|
|
if (my $el = $self->dom->at('div[itemprop="articleBody"]')) { |
16
|
|
|
|
|
|
|
return html2text( $el->to_string ); |
17
|
0
|
|
|
0
|
0
|
|
} |
18
|
0
|
0
|
|
|
|
|
return undef; |
19
|
0
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my ($self) = @_; |
22
|
|
|
|
|
|
|
if (my $el = $self->dom->at('p[itemprop="datePublished"]')) { |
23
|
|
|
|
|
|
|
return $el->attr("datetime"); |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
0
|
0
|
|
return undef; |
26
|
0
|
0
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my ($self) = @_; |
29
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
if (my $el = $self->dom->at("div.artical-content")) { |
32
|
|
|
|
|
|
|
my $p_first = $el->at("p"); |
33
|
0
|
|
|
0
|
0
|
|
my $line = $p_first->all_text; |
34
|
|
|
|
|
|
|
if ($line =~ m{([\p{Letter}\p{Space}])報導\s*/\s*\p{Letter}{1,5}}) { |
35
|
|
|
|
|
|
|
return normalize_whitespace($line); |
36
|
0
|
0
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
my @patterns = ( |
40
|
0
|
|
|
|
|
|
qr{^(.+?\s*報導\s*/\s*\S+)\s?\n}, |
41
|
|
|
|
|
|
|
qr<\A (\p{Letter}+? \s+ 採訪/撰稿 \s+ \p{Letter}+? \s+ 攝影/剪輯) \s+ />x, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $content_text = $self->content_text; |
45
|
|
|
|
|
|
|
my @matched; |
46
|
|
|
|
|
|
|
for my $pat (@patterns) { |
47
|
|
|
|
|
|
|
@matched = $content_text =~ m/$pat/; |
48
|
|
|
|
|
|
|
last if @matched; |
49
|
0
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $matched[0]; |
52
|
0
|
|
|
|
|
|
} |
53
|
0
|
0
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |