Added new contrib/getquote-uk.py script
This commit is contained in:
parent
bc1a196f02
commit
6e4581690d
1 changed files with 23 additions and 0 deletions
23
contrib/getquote-uk.py
Executable file
23
contrib/getquote-uk.py
Executable file
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue