line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewsExtractor::SiteSpecificExtractor::www_hkcnews_com; |
2
|
1
|
|
|
1
|
|
9
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
35
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
extends 'NewsExtractor::GenericExtractor'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
around headline => sub { |
7
|
|
|
|
|
|
|
my $orig = shift; |
8
|
|
|
|
|
|
|
my $self = $_[0]; |
9
|
|
|
|
|
|
|
my $headline = $orig->(@_); |
10
|
|
|
|
|
|
|
my $journalist = $self->journalist(); |
11
|
|
|
|
|
|
|
$headline =~ s/\s\|\s${journalist}$//; |
12
|
|
|
|
|
|
|
return $headline; |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub journalist { |
16
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
17
|
0
|
|
|
|
|
|
my $el = $self->dom->at('.article-info'); |
18
|
0
|
|
|
|
|
|
my ($n) = $el->all_text =~ m{^(?:Author|撰文): (?:(?:特約)?記者)?(.+?) \|}; |
19
|
0
|
|
|
|
|
|
return $n; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub dateline { |
23
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
24
|
0
|
|
|
|
|
|
my $el = $self->dom->at('.article-info'); |
25
|
0
|
|
|
|
|
|
my ($dd,$mm,$yy) = $el->all_text =~ m{(?:發佈日期|Publish Date):\s([0-9]{2})\.([0-9]{2})\.([0-9]{2})\b}; |
26
|
0
|
0
|
0
|
|
|
|
return undef unless ($dd && $mm && $yy); |
|
|
|
0
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return "20${yy}-${mm}-${dd}T23:59:59+08:00"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |