diff options
author | Mark Carter <alt.mcarter@googlemail.com> | 2009-02-23 13:24:28 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-23 14:35:04 -0400 |
commit | 6e4581690de4aef96895177ac5d5ed66e9cec5d8 (patch) | |
tree | 9bdcc90c8300ad4c180fe1577cfabf68842cb162 /contrib/getquote-uk.py | |
parent | bc1a196f02e1db913dcfb1341abec03332e5c589 (diff) | |
download | fork-ledger-6e4581690de4aef96895177ac5d5ed66e9cec5d8.tar.gz fork-ledger-6e4581690de4aef96895177ac5d5ed66e9cec5d8.tar.bz2 fork-ledger-6e4581690de4aef96895177ac5d5ed66e9cec5d8.zip |
Added new contrib/getquote-uk.py script
Diffstat (limited to 'contrib/getquote-uk.py')
-rwxr-xr-x | contrib/getquote-uk.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/contrib/getquote-uk.py b/contrib/getquote-uk.py new file mode 100755 index 00000000..a69d4e7d --- /dev/null +++ b/contrib/getquote-uk.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import urllib, string, sys + +def download(sym): + url = "http://uk.old.finance.yahoo.com/d/quotes.csv?s=" + url += sym + "&f=sl1d1t1c1ohgv&e=.csv" + f = urllib.urlopen(url, proxies={}) + info = f.read() + f.close() + fields = string.split(info, ',') + result = float(fields[1])/100 + return result + + +sym = sys.argv[1] +sym = sym.replace('_', '.') +if sym == '£': + print '£1.00' +else: + try: print "£" +str(download(sym)) + except: pass |