Can anyone debug this code and provide us the working code to be used with Python 3.2.1 for Windows.
import urllib2
import json
import time
class GoogleFinanceAPI:
def __init__(self):
self.prefix = "http://finance.google.com/finance/info?client=ig&q="
def get(self,symbol,exchange):
url = self.prefix+"%s:%s"%(exchange,symbol)
u = urllib2.urlopen(url)
content = u.read()
obj = json.loads(content[3:])
return obj[0]
if __name__ == "__main__":
c = GoogleFinanceAPI()
while 1:
quote = c.get("MSFT","NASDAQ")
print quote
time.sleep(30)
The above code prints the Quote for Microsoft stock on NASDAQ every 30 seconds.
This is a code found on Net - It is not at all mine.
For more details - http://digitalpbk.com/stock/google-finance-get-stock-quote-realtime
import urllib2
import json
import time
class GoogleFinanceAPI:
def __init__(self):
self.prefix = "http://finance.google.com/finance/info?client=ig&q="
def get(self,symbol,exchange):
url = self.prefix+"%s:%s"%(exchange,symbol)
u = urllib2.urlopen(url)
content = u.read()
obj = json.loads(content[3:])
return obj[0]
if __name__ == "__main__":
c = GoogleFinanceAPI()
while 1:
quote = c.get("MSFT","NASDAQ")
print quote
time.sleep(30)
The above code prints the Quote for Microsoft stock on NASDAQ every 30 seconds.
This is a code found on Net - It is not at all mine.
For more details - http://digitalpbk.com/stock/google-finance-get-stock-quote-realtime