--- lib/Finance/Quote.pm 2008-10-26 04:15:50.000000000 -0400
+++ /opt/local/lib/perl5/vendor_perl/5.8.9/Finance/Quote.pm 2009-05-16 01:22:08.000000000 -0400
@@ -36,14 +36,16 @@
use Finance::Quote::UserAgent;
use HTTP::Request::Common;
use HTML::TableExtract;
+use Finance::Quote::Yahoo::Base qw/yahoo_request/;
use vars qw/@ISA @EXPORT @EXPORT_OK @EXPORT_TAGS
$VERSION $TIMEOUT %MODULES %METHODS $AUTOLOAD
$YAHOO_CURRENCY_URL $USE_EXPERIMENTAL_UA/;
-$YAHOO_CURRENCY_URL = "
http://uk.finance.yahoo.com/currency/convert?amt=1&submit=Convert&";
+# $YAHOO_CURRENCY_URL = "
http://uk.finance.yahoo.com/currency/convert?amt=1&submit=Convert&";
# If the above URL ever fails, try rewriting this module to use the URL below.
# $YAHOO_CURRENCY_URL = "
http://uk.finance.yahoo.com/q?s=USDCAD%3DX";
+$YAHOO_CURRENCY_URL = "
http://finance.yahoo.com/d";
@ISA = qw/Exporter/;
@EXPORT = ();
@@ -236,17 +238,13 @@
return $amount if ($from eq $to); # Trivial case.
- my $ua = $this->user_agent;
-
- my $data = $ua->request(GET "${YAHOO_CURRENCY_URL}from=$from&to=$to")->content;
- my $te = HTML::TableExtract->new( headers => ['Symbol', 'Bid', 'Ask'] );
- $te->parse($data);
-
- # Make sure there's a table to parse.
- return undef unless ($te->tables);
-
- my $row = ($te->rows())[0];
- my ($exchange_rate) = $$row[1];
+ my $symbol = "$from$to=X";
+ my @symbols = ($symbol);
+ my %info = yahoo_request($this,$YAHOO_CURRENCY_URL,\@symbols);
+ return undef unless $info{$symbol,"success"};
+
+ my $exchange_rate = $info{$symbol,"last"};
+
$exchange_rate =~ s/,// ; # solve a bug when conversion rate
# involves thousands. yahoo inserts
# a comma when thousands occur