line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Finance::Quote Perl module to retrieve quotes from Finanzpartner.de |
2
|
|
|
|
|
|
|
# Copyright (C) 2007 Jan Willamowius <jan@willamowius.de> |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
5
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
6
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
7
|
|
|
|
|
|
|
# (at your option) any later version. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
10
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
|
|
|
|
# GNU General Public License for more details. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
15
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
16
|
|
|
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Finance::Quote::Finanzpartner; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
5
|
|
2617
|
use strict; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
195
|
|
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
|
34
|
use constant DEBUG => $ENV{DEBUG}; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
318
|
|
23
|
5
|
|
|
5
|
|
38
|
use if DEBUG, 'Smart::Comments'; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
26
|
|
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
5
|
|
174
|
use Web::Scraper; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
35
|
|
26
|
5
|
|
|
5
|
|
393
|
use Encode; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
3166
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '1.58'; # VERSION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $FINANZPARTNER_URL = "https://www.finanzpartner.de/fi/"; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
5
|
0
|
25
|
sub methods {return (finanzpartner => \&finanzpartner);} |
33
|
5
|
|
|
5
|
0
|
18
|
sub labels { return (finanzpartner=>[qw/name date price last method/]); } # TODO |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub finanzpartner |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
0
|
|
my $quoter = shift; # The Finance::Quote object. |
38
|
0
|
|
|
|
|
|
my @stocks = @_; |
39
|
0
|
|
|
|
|
|
my $ua = $quoter->user_agent(); |
40
|
0
|
|
|
|
|
|
my %info; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
foreach my $stock (@stocks) { |
43
|
0
|
|
|
|
|
|
eval { |
44
|
0
|
|
|
|
|
|
my @headers = ( |
45
|
|
|
|
|
|
|
"authority" => "www.finanzpartner.de", |
46
|
|
|
|
|
|
|
"sec-ch-ua" => '"Google Chrome";v="87", " Not;A Brand";v="99", "Chromium";v="87"', |
47
|
|
|
|
|
|
|
"sec-ch-ua-mobile" => "?0", |
48
|
|
|
|
|
|
|
"upgrade-insecure-requests" => "1", |
49
|
|
|
|
|
|
|
"user-agent" => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36', |
50
|
|
|
|
|
|
|
"accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", |
51
|
|
|
|
|
|
|
"accept-language" => "en-US,en;q=0.9", |
52
|
|
|
|
|
|
|
"sec-ch-ua" => "\"Google Chrome\";v=\"87\", \" Not;A Brand\";v=\"99\", \"Chromium\";v=\"87\"", |
53
|
|
|
|
|
|
|
"sec-fetch-dest" => "document", |
54
|
|
|
|
|
|
|
"sec-fetch-mode" => "navigate", |
55
|
|
|
|
|
|
|
"sec-fetch-site" => "none", |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $url = $FINANZPARTNER_URL . $stock . '/'; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
### url : $url |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $reply = $ua->get($url, @headers); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $processor = scraper { |
65
|
0
|
|
|
0
|
|
|
process 'span.kurs-m.pull-left', 'price[]' => 'TEXT'; |
66
|
0
|
|
|
|
|
|
process 'h1 > small', 'isin[]' => 'TEXT'; |
67
|
0
|
|
|
|
|
|
process 'div.col-md-2', 'date[]' => 'TEXT'; |
68
|
0
|
|
|
|
|
|
process 'h1 > span', 'name[]' => 'TEXT'; |
69
|
0
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $data = $processor->scrape(decode_utf8 $reply->content); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
### data: $data |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
0
|
|
|
|
die "Unexpected price format" unless exists $data->{price} and $data->{price}->[0] =~ /^([0-9.]+) ([A-Z]+)$/; |
76
|
0
|
|
|
|
|
|
$info{$stock, "last"} = $1; |
77
|
0
|
|
|
|
|
|
$info{$stock, "currency"} = $2; |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
0
|
|
|
|
die "Unexpected date format" unless exists $data->{date} and $data->{date}->[0] =~ /([0-9]{2}[.][0-9]{2}[.][0-9]{4})$/; |
80
|
0
|
|
|
|
|
|
$quoter->store_date(\%info, $stock, {eurodate => $1}); |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$info{$stock,"method"} = "finanzpartner"; |
83
|
0
|
|
|
|
|
|
$info{$stock,"symbol"} = $stock; |
84
|
0
|
|
|
|
|
|
$info{$stock,"success"} = 1; |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
if ($@) { |
88
|
0
|
|
|
|
|
|
$info{$stock,"errormsg"} = $@; |
89
|
0
|
|
|
|
|
|
$info{$stock,"success"} = 0; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
return wantarray ? %info : \%info; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Finance::Quote::Finanzpartner - Obtain quotes from Finanzpartner.de. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SYNOPSIS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use Finance::Quote; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$q = Finance::Quote->new("Finanzpartner"); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
%info = $q->fetch("finanzpartner","LU0055732977"); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This module obtains quotes from Finanzpartner.de (http://www.finanzpartner.de) by WKN or ISIN. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 LABELS RETURNED |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The following labels may be returned by Finance::Quote::Finanzpartner: |
117
|
|
|
|
|
|
|
name, date, price, last, method. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SEE ALSO |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Finanzpartner, http://www.finanzpartner.de/ |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Finance::Quote; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |