line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewsExtractor::SiteSpecificExtractor::focustaiwan_tw; |
2
|
1
|
|
|
1
|
|
7
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
3
|
1
|
|
|
1
|
|
33
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
extends 'NewsExtractor::GenericExtractor'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
369
|
use Importer 'NewsExtractor::TextUtil' => qw(u); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub dateline { |
9
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Example: <div class="updatetime">07/10/2020 10:59 PM</div> |
12
|
0
|
|
|
|
|
|
my $dateline = $self->dom->at('div.updatetime')->all_text; |
13
|
0
|
|
|
|
|
|
my @t = $dateline =~ m/([0-9]+)/g; |
14
|
0
|
0
|
|
|
|
|
$t[3] += 12 if $dateline =~ /PM\z/; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
return u(sprintf( |
17
|
|
|
|
|
|
|
'%04d-%02d-%02dT%02d:%02d:%02d+08:00', |
18
|
|
|
|
|
|
|
$t[2], # year |
19
|
|
|
|
|
|
|
$t[0], # month |
20
|
|
|
|
|
|
|
$t[1], # mday |
21
|
|
|
|
|
|
|
$t[3], # hour |
22
|
|
|
|
|
|
|
$t[4], # minute |
23
|
|
|
|
|
|
|
59, # sec |
24
|
|
|
|
|
|
|
)); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub journalist { |
28
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
29
|
0
|
0
|
|
|
|
|
my $el = $self->dom->at('div.author > p') or return; |
30
|
0
|
|
|
|
|
|
return $el->all_text =~ s/\s*\(By\s+(.+)\)\s*/$1/r; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |