line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewsExtractor::SiteSpecificExtractor::news_pts_org_tw; |
2
|
1
|
|
|
1
|
|
8
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
3
|
1
|
|
|
1
|
|
51
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'NewsExtractor::JSONLDExtractor'; |
6
|
|
|
|
|
|
|
with 'NewsExtractor::Role::ContentTextExtractor'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
315
|
use HTML::ExtractContent; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
35
|
|
9
|
1
|
|
|
1
|
|
6
|
use Importer 'NewsExtractor::TextUtil' => ('html2text', 'reformat_dateline'); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
36
|
use Importer 'Ref::Util' => ('is_hashref'); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub journalist { |
13
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
14
|
0
|
|
|
|
|
|
my $name; |
15
|
0
|
|
|
|
|
|
my $author = $self->schema_ld->{author}; |
16
|
0
|
0
|
0
|
|
|
|
if (is_hashref($author) && exists($author->{"name"})) { |
17
|
0
|
|
|
|
|
|
$name = $author->{"name"}; |
18
|
|
|
|
|
|
|
} else { |
19
|
0
|
|
|
|
|
|
$name = $author; |
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
|
return $name; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
around dateline => sub { |
25
|
|
|
|
|
|
|
my $orig = shift; |
26
|
|
|
|
|
|
|
my $ret = $orig->(@_); |
27
|
|
|
|
|
|
|
return reformat_dateline($ret, '+08:00'); |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
around '_build_content_text', sub { |
31
|
|
|
|
|
|
|
my $orig = shift; |
32
|
|
|
|
|
|
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
if (my $el = $self->dom->at('article.post-article')) { |
35
|
|
|
|
|
|
|
my $extractor = HTML::ExtractContent->new; |
36
|
|
|
|
|
|
|
my $html = $extractor->extract("$el")->as_html; |
37
|
|
|
|
|
|
|
my $text = html2text( $html ); |
38
|
|
|
|
|
|
|
return $text; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return $orig->($self); |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |