Finance/Quote/Morningstarde.pm: rework logic to use id-map and base-url
This commit is contained in:
parent
9b40eaa957
commit
f2229bca6d
@ -23,23 +23,13 @@ use POSIX qw(strftime);
|
||||
|
||||
my $agent_string = 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0';
|
||||
|
||||
my %urlmap_wkn = (
|
||||
'986855' => 'https://www.morningstar.de/de/funds/snapshot/snapshot.aspx?id=F0GBR04DI1'
|
||||
);
|
||||
sub baseurl {
|
||||
return 'https://www.morningstar.de/de/funds/snapshot/snapshot.aspx?id=';
|
||||
}
|
||||
|
||||
my %wknmap = (
|
||||
'de0005326565' => '532656',
|
||||
'de000a0m8hd2' => 'a0m8hd',
|
||||
'de000a0x7541' => 'a0x754',
|
||||
'de000a0x7582' => 'a0x758',
|
||||
'de000ewg0ld1' => 'ewg0ld',
|
||||
'fr0010135103' => 'a0dpw0',
|
||||
'lu0087412390' => '974515',
|
||||
'lu0323578657' => 'a0m430',
|
||||
'lu0327386487' => 'dws0pr',
|
||||
'lu0336084032' => 'a0m9a2',
|
||||
'lu0438336264' => 'a0ndda',
|
||||
'lu0454071019' => 'a0ya5q'
|
||||
my %idmap = (
|
||||
'986855' => 'F0GBR04DI1',
|
||||
'lu0048293285' => 'F0GBR04DI1',
|
||||
);
|
||||
|
||||
sub methods {return ('morningstarde' => \&morningstarde);}
|
||||
@ -52,12 +42,10 @@ sub labels { return (morningstarde => \@labels); }
|
||||
sub get_stock_url {
|
||||
my $stock_wkn = shift;
|
||||
|
||||
my $url = $urlmap_wkn{lc($stock_wkn)};
|
||||
if (!defined($url) || length($url) == 0) {
|
||||
my $wkn = $wknmap{lc($stock_wkn)};
|
||||
$url = $urlmap_wkn{$wkn};
|
||||
}
|
||||
return $url;
|
||||
my $id = $idmap{lc($stock_wkn)};
|
||||
if (defined($id)) {
|
||||
return baseurl() . $id;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +93,6 @@ sub morningstarde
|
||||
|
||||
my $datestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[2]/td[1]//span');
|
||||
if (defined($datestr)) {
|
||||
print "got datestr: $datestr\r\n";
|
||||
my $tradedate = $datestr;
|
||||
$tradedate =~ s/.*\|\s*(\d\d.*) $/$1/g;
|
||||
if (length($tradedate) < 10) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user