summaryrefslogtreecommitdiff
path: root/contrib/getquote-uk.py
blob: a69d4e7d6b9069456c6da6054bb4e2afcce52b12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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