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;
|
$info{$stock,'name'} = $namestr;
|
||||||
};
|
};
|
||||||
|
|
||||||
my $pricestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[2]/td[3]');
|
my $row = 2;
|
||||||
if (defined($pricestr)) {
|
while (!defined($info{$stock,'currency'}) && $row <=10) {
|
||||||
my @splitvals = ( $pricestr =~ /(\w+).([0-9,.]+)/g);
|
my $pricestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[' . $row . ']/td[3]');
|
||||||
if (@splitvals) {
|
if (defined($pricestr)) {
|
||||||
$info{$stock,'currency'} = $splitvals[0];
|
my @splitvals = ( $pricestr =~ /(\w+).([0-9,.]+)/g);
|
||||||
my $converted_price = $splitvals[1];
|
if (@splitvals) {
|
||||||
$converted_price =~ s/\.//g;
|
$info{$stock,'currency'} = $splitvals[0];
|
||||||
$converted_price =~ s/,/./g;
|
my $converted_price = $splitvals[1];
|
||||||
$info{$stock,'nav'} = $converted_price;
|
$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');
|
my $datestr = $parser->findnodes('//div[@id="overviewQuickstatsDiv"]//tr[2]/td[1]//span');
|
||||||
if (defined($datestr)) {
|
if (defined($datestr)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user