/usr/share/perl5/Finance/Quote/Deka.pm is in libfinance-quote-perl 1.38-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | # Finance::Quote Perl module to retrieve prices of Deka funds
# Copyright (C) 2005 Knut Franke <Knut.Franke@gmx.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
package Finance::Quote::Deka;
use strict;
use HTML::TableExtract;
require LWP::Protocol::https;
our $VERSION = '1.38'; # VERSION
my $DEKA_URL = "https://www.deka.de/dn/useCases/fundsearch/UCFundsSearch.shtml?ACTION_FIELD=quickSearch";
sub methods {return (deka => \&deka);}
sub labels { return (deka=>[qw/name date price last method/]); }
# Trim leading and tailing whitespaces (also non-breakable whitespaces)
sub trim
{
$_ = shift();
s/^\s*//;
s/\s*$//;
s/ //g;
return $_;
}
# Convert number separators to US values
sub convert_price {
$_ = shift;
s/\./@/g;
s/,/\./g;
s/@/,/g;
return $_;
}
sub deka
{
my $quoter = shift; # The Finance::Quote object.
my @stocks = @_;
my $ua = $quoter->user_agent();
my %info;
foreach my $stock (@stocks) {
my $response = $ua->get($DEKA_URL . "&isin=" . $stock);
# print $response->content, "\n";
$info{$stock,"success"} = 0;
if (!$response -> is_success()) {
$info{$stock,"errormsg"} = "HTTP failure";
} else {
my $te = new HTML::TableExtract();
$te->parse($response->content);
foreach my $ts ($te->table_states) {
# foreach my $row ($ts->rows) {
# next if !defined $$row[0] || !defined $$row[1];
# print "Row: ", join('|', @$row), "\n";
# }
foreach my $row ($ts->rows) {
next if !defined $$row[0] || !defined $$row[1];
next if !defined $$row[2] || !defined $$row[3];
$info{$stock,"currency"} = $$row[1] if( $$row[0] =~ /^W.hrung:$/ );
$info{$stock,"price"} = convert_price(trim($$row[3])) if( $$row[2] eq "Anteilpreis Aktuell:" );
}
}
$info{$stock,"name"} = $1
if( $response->content =~ /<div class="sfg_txt">[^<>]*<h1>([^<>]+)<\/h1>/s );
$info{$stock,"eurodate"} = $1
if( $response->content =~ /<h2 class="headline">Aktuelle Fondsdaten vom ([^<>]+)<\/h2>/s );
$info{$stock,"last"} = $info{$stock,"price"}
if( defined $info{$stock,"price"} );
$info{$stock,"success"} = 1
if( defined $info{$stock,"name"}
&& defined $info{$stock,"eurodate"}
&& defined $info{$stock,"price"}
&& defined $info{$stock,"last"}
&& defined $info{$stock,"currency"} );
if( $info{$stock,"success"} == 1 )
{
$info{$stock,"method"} = "deka";
$info{$stock,"symbol"} = $stock;
$quoter->store_date(\%info, $stock, {eurodate => $info{$stock,"eurodate"}});
delete $info{$stock,"eurodate"};
}
$info{$stock,"errormsg"} = "Couldn't parse deka website"
if ($info{$stock,"success"} == 0);
}
}
return wantarray ? %info : \%info;
}
1;
=head1 NAME
Finance::Quote::Deka - Obtain fonds quotes from DekaBank.
=head1 SYNOPSIS
use Finance::Quote;
$q = Finance::Quote->new("Deka");
%info = Finance::Quote->fetch("deka","DE0008474511");
=head1 DESCRIPTION
This module obtains fund prices from DekaBank,
http://www.deka.de/. Deka website supports retrieval by name, WKN or ISIN.
=head1 LABELS RETURNED
The following labels may be returned by Finance::Quote::Deka:
name, date, price, last, method.
=head1 SEE ALSO
DekaBank, http://www.deka.de/
Finance::Quote;
=cut
|