Skip to content

Instantly share code, notes, and snippets.

@abiank
Forked from border/googleFinance.py
Created March 4, 2014 17:05
Show Gist options
  • Save abiank/9350715 to your computer and use it in GitHub Desktop.
Save abiank/9350715 to your computer and use it in GitHub Desktop.
import urllib2
import json
import time
# Form: http://digitalpbk.com/stock/google-finance-get-stock-quote-realtime
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment