Skip to content

Instantly share code, notes, and snippets.

View madeleine68's full-sized avatar
🏠
Working from home

Madeleine madeleine68

🏠
Working from home
View GitHub Profile
with open("sp500tickers.pickle", "rb") as f:
tickers = pickle.load(f)
if not os.path.exists('stock_dfs'):
os.makedirs('stock_dfs')
import datetime as dt
import os
import pandas_datareader.data as pdr
with open("sp500tickers.pickle", "wb") as f:
pickle.dump(tickers, f)
tickers = []
for row in table.findAll('tr')[1:]:
ticker = row.findAll('td')[0].text
ticker = ticker[:-1]
tickers.append(ticker)
html = requests.get('http://en.wikipedia.org/wiki/List_of_S%26P_500_companies')
soup = bs.BeautifulSoup(html.text, 'lxml')
table = soup.find('table', {'class': 'wikitable sortable'})
import bs4 as bs
import pickle
import requests