Cannot get CURRENCY:EUR price since Monday

Mike Alexander mta at umich.edu
Sat May 16 01:40:51 EDT 2009


--On May 15, 2009 8:37:44 PM +0100 AmigaPhil <AmigaPhil at ping.be> wrote:

> Phil Reynolds wrote:
>
>> I have been using gnucash for quite some time and have been very
>> impressed with it. However, since the last successful attempt on
>> Monday, I have been unable to get the price. If I try, I see:
>>
>> Unable to retrieve quotes for these items:
>>    CURRENCY:EUR
>>
>> This is the only price I now have to look up.
>>
>> I am using the default setup on Debian lenny (GnuCash 2.2.6 with
>> Finance::Quote 1.13), but have also tried 1.15 and 1.16, patched as
>> per the suggestion to fix some other problems. No difference at all
>> to the result.
>>
>> I am not sure how to proceed from here with tracking this one down.
>> If anyone can advise how I proceed, I will certainly try, and report
>> back.
>
> Yahoo has changed its Currency Convertor.
>
> See my post: "Currency online update - broken ?"
> http://lists.gnucash.org/pipermail/gnucash-user/2009-May/029892.html

The currency module of Finance::Quote gets its data by screen scraping 
a page at a URL starting with 
<http://uk.finance.yahoo.com/currency/convert?amt=1&submit=Convert>. 
Yahoo recently changed this page so the screen scraping doesn't work 
(and can't easily be made to work).  The easy solution is to use the 
existing Finance::Quote Yahoo module which already knows how to get 
currency quotes.  I've got a patch to Quote.pm which does this which 
I'll try to attach to this message.  It seems to fix the problem for me.

     Mike
-------------- next part --------------
--- 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


More information about the gnucash-user mailing list