Finance/Quote/Morningstarde.pm: parse dynamic table-row for currency
This commit is contained in:
parent
a56620543e
commit
960ad436f6
@ -84,17 +84,26 @@ sub morningstarde
|
||||
$info{$stock,'name'} = $namestr;
|
||||
};
|
||||
|
||||
my $pricestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[2]/td[3]');
|
||||
if (defined($pricestr)) {
|
||||
my @splitvals = ( $pricestr =~ /(\w+).([0-9,.]+)/g);
|
||||
if (@splitvals) {
|
||||
$info{$stock,'currency'} = $splitvals[0];
|
||||
my $converted_price = $splitvals[1];
|
||||
$converted_price =~ s/\.//g;
|
||||
$converted_price =~ s/,/./g;
|
||||
$info{$stock,'nav'} = $converted_price;
|
||||
}
|
||||
};
|
||||
my $row = 2;
|
||||
while (!defined($info{$stock,'currency'}) && $row <=10) {
|
||||
my $pricestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[' . $row . ']/td[3]');
|
||||
if (defined($pricestr)) {
|
||||
my @splitvals = ( $pricestr =~ /(\w+).([0-9,.]+)/g);
|
||||
if (@splitvals) {
|
||||
$info{$stock,'currency'} = $splitvals[0];
|
||||
my $converted_price = $splitvals[1];
|
||||
$converted_price =~ s/\.//g;
|
||||
$converted_price =~ s/,/./g;
|
||||
$info{$stock,'nav'} = $converted_price;
|
||||
}
|
||||
|
||||
# if it does not look like a currency, try next row
|
||||
if ($info{$stock,'currency'} !~ /\w{2,3}/) {
|
||||
undef $info{$stock,'currency'};
|
||||
}
|
||||
$row++;
|
||||
};
|
||||
}
|
||||
|
||||
my $datestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[2]/td[1]//span');
|
||||
if (defined($datestr)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user