line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
use v5.18; |
2
|
1
|
|
|
1
|
|
12
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
3
|
1
|
|
|
1
|
|
6
|
use Types::Standard qw< InstanceOf >; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
272
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
5
|
|
|
|
|
|
|
has tx => ( required => 1, is => 'ro', isa => InstanceOf['Mojo::Transaction::HTTP']); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use NewsExtractor::Article; |
8
|
1
|
|
|
1
|
|
1063
|
use NewsExtractor::Extractor; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
9
|
1
|
|
|
1
|
|
328
|
use NewsExtractor::Error; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
10
|
1
|
|
|
1
|
|
7
|
use Importer 'NewsExtractor::TextUtil' => qw(u is_empty); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
11
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
use Try::Tiny; |
13
|
1
|
|
|
1
|
|
30
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
310
|
|
14
|
|
|
|
|
|
|
my $self = $_[0]; |
15
|
|
|
|
|
|
|
my ($err, $o, %article); |
16
|
0
|
|
|
0
|
0
|
|
|
17
|
0
|
|
|
|
|
|
try { |
18
|
|
|
|
|
|
|
my $x = NewsExtractor::Extractor->new( tx => $self->tx ); |
19
|
|
|
|
|
|
|
$article{headline} = $x->headline; |
20
|
0
|
|
|
0
|
|
|
$article{article_body} = $x->content_text; |
21
|
0
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
for my $it (qw(dateline journalist)) { |
23
|
|
|
|
|
|
|
my $v = $x->$it; |
24
|
0
|
|
|
|
|
|
if (defined($v)) { |
25
|
0
|
|
|
|
|
|
$article{$it} = $v; |
26
|
0
|
0
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
for my $it (qw(headline article_body)) { |
30
|
|
|
|
|
|
|
if (is_empty($article{$it})) { |
31
|
0
|
|
|
|
|
|
$err = NewsExtractor::Error->new( |
32
|
0
|
0
|
|
|
|
|
message => u("Failed to extract: $it") |
33
|
0
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
last; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$o = NewsExtractor::Article->new(%article); |
39
|
|
|
|
|
|
|
} catch { |
40
|
0
|
|
|
|
|
|
my $e = $_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
|
|
if (ref($e) && $e->isa('Error::TypeTiny::Assertion')) { |
43
|
|
|
|
|
|
|
$e = $e->message; |
44
|
0
|
0
|
0
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$err = NewsExtractor::Error->new( |
47
|
|
|
|
|
|
|
message => u($e), |
48
|
0
|
|
|
|
|
|
debug => { articleArgs => \%article }, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return ($err, $o); |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |