line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NewsExtractor::SiteSpecificExtractor::www_bcc_com_tw; |
2
|
1
|
|
|
1
|
|
8
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
3
|
1
|
|
|
1
|
|
35
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
extends 'NewsExtractor::SiteSpecificExtractor'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
345
|
use Importer 'NewsExtractor::TextUtil' => 'html2text'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub headline { |
9
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
10
|
0
|
|
|
|
|
|
my $el = $self->dom->at('head > title'); |
11
|
0
|
|
|
|
|
|
return $el->all_text; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub dateline { |
15
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
16
|
0
|
0
|
|
|
|
|
my $el = $self->dom->at('div.tt27') or return undef; |
17
|
0
|
|
|
|
|
|
my $txt = $el->all_text; |
18
|
0
|
|
|
|
|
|
$txt =~ s/\s+報導\z//; |
19
|
0
|
|
|
|
|
|
return $txt; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub journalist { |
23
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
24
|
0
|
0
|
|
|
|
|
my $content = $self->content_text or return undef; |
25
|
0
|
|
|
|
|
|
my ($o) = $content =~ m{。 [(\(] (\p{Letter}+?) 報導 [)\)] \n\n}x; |
26
|
0
|
0
|
|
|
|
|
unless ($o) { |
27
|
0
|
|
|
|
|
|
($o) = $content =~ m{。 [(\(] 中廣記者 (\p{Letter}+?) [)\)] \z}x; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
return $o; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub content_text { |
33
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
34
|
0
|
|
|
|
|
|
my $el; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
for $el ($self->dom->find('script, div.ft')->each) { |
37
|
0
|
|
|
|
|
|
$el->remove(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
$el = $self->dom->at('#some-class-name') or return undef; |
41
|
0
|
|
|
|
|
|
return html2text( $el->to_string ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |