Skip to content

Instantly share code, notes, and snippets.

@davetromp
Created March 13, 2017 17:01
Show Gist options
  • Save davetromp/df0aafd68b25f2d973cea4ff0271088f to your computer and use it in GitHub Desktop.
Save davetromp/df0aafd68b25f2d973cea4ff0271088f to your computer and use it in GitHub Desktop.
import urllib.request
def getData(ticker):
url = "http://chart.finance.yahoo.com/table.csv?s={}&a=1&b=12&c=2017&d=2&e=12&f=2017&g=d&ignore=.csv".format(ticker)
data = urllib.request.urlopen(url)
doc = open("yahoo_finance_{}.csv".format(ticker), 'w')
doc.write(data.read().decode("utf8"))
doc.close()
tickers = ["AAPL", "IBM", "SAM"]
for ticker in tickers:
getData(ticker)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment