| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Grizzly::Command::news; |
|
2
|
2
|
|
|
2
|
|
7818
|
use Grizzly -command; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
17
|
|
|
3
|
2
|
|
|
2
|
|
553
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
45
|
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
48
|
|
|
5
|
2
|
|
|
2
|
|
912
|
use open ':std', ':encoding(UTF-8)'; |
|
|
2
|
|
|
|
|
2076
|
|
|
|
2
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
29532
|
use Finance::Quote; |
|
|
2
|
|
|
|
|
114301
|
|
|
|
2
|
|
|
|
|
96
|
|
|
8
|
2
|
|
|
2
|
|
924
|
use Web::NewsAPI; |
|
|
2
|
|
|
|
|
2111776
|
|
|
|
2
|
|
|
|
|
76
|
|
|
9
|
2
|
|
|
2
|
|
1024
|
use Grizzly::Progress::Bar; |
|
|
2
|
|
|
|
|
25
|
|
|
|
2
|
|
|
|
|
720
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $q = Finance::Quote->new("YahooJSON"); |
|
12
|
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
1
|
0
|
sub abstract { "display stock news" } |
|
14
|
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
1
|
0
|
sub description { "Display the any news on the stock." } |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub validate_args { |
|
18
|
3
|
|
|
3
|
1
|
5106470
|
my ( $self, $opt, $args ) = @_; |
|
19
|
3
|
100
|
|
|
|
23
|
$self->usage_error("Need a symbol args") unless @$args; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub execute { |
|
23
|
2
|
|
|
2
|
1
|
12
|
my ( $self, $opt, $args ) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
7
|
quote_info(@$args); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub quote_info { |
|
29
|
2
|
|
|
2
|
0
|
6
|
my ($symbol) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
5
|
my $article_number = 1; |
|
32
|
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
21
|
my %quote = $q->yahoo_json($symbol); |
|
34
|
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
399987
|
Grizzly::Progress::Bar->progressbar(); |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $name = $quote{ $symbol, "name" }; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $api_key = $ENV{'NEWS_API_KEY'}; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $newsapi = Web::NewsAPI->new( api_key => $api_key, ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
unless ($name) { |
|
44
|
0
|
|
|
|
|
|
$name = $symbol; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
print "Here are the top ten headlines worldwide for $name...\n"; |
|
48
|
0
|
|
|
|
|
|
print "\n"; |
|
49
|
0
|
|
|
|
|
|
my $stock_news = $newsapi->everything( q => $name, pageSize => 10 ); |
|
50
|
0
|
|
|
|
|
|
for my $article ( $stock_news->articles ) { |
|
51
|
0
|
|
|
|
|
|
print "$article_number: \n" . $article->title . "\n"; |
|
52
|
0
|
|
|
|
|
|
print "Link: " . $article->url . "\n"; |
|
53
|
0
|
|
|
|
|
|
print "Description: " . $article->description . "\n"; |
|
54
|
0
|
|
|
|
|
|
print "\n"; |
|
55
|
0
|
|
|
|
|
|
$article_number += 1; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
0
|
|
|
|
|
|
print "The total number of $name articles returned: " |
|
58
|
|
|
|
|
|
|
. $stock_news->total_results . "\n"; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Grizzly::Command::news |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 0.102 |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
grizzly news [stock symbol] |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The news feture will output stock in formation on the inputted ticker symbol. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Grizzly::Command::news |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 API Key |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
You will need to get a free API key from L<NewsAPI|https://newsapi.org/>. Afterwards you will need to set the NEWS_API_KEY environment variable to the API key. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Nobunaga <nobunaga@cpan.org> |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Nobunaga. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
MIT License |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Nobunaga <nobunaga@cpan.org> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This software is Copyright (c) 2021 by Nobunaga. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is free software, licensed under: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The MIT (X11) License |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |