MCPcopy Index your code
hub / github.com/gto76/python-cheatsheet / scrape_yahoo

Function scrape_yahoo

web/update_plots.py:56–60  ·  view source on GitHub ↗
(slug)

Source from the content-addressed store, hash-verified

54 df = pd.read_csv(url, usecols=['location', 'date', 'total_cases'])
55 return df[df.location == 'World'].set_index('date').total_cases
56 def scrape_yahoo(slug):
57 url = f'https://query1.finance.yahoo.com/v7/finance/download/{slug}' + \
58 '?period1=1579651200&period2=9999999999&interval=1d&events=history'
59 df = pd.read_csv(url, usecols=['Date', 'Close'])
60 return df.set_index('Date').Close
61 out = [scrape_covid(), scrape_yahoo('BTC-USD'), scrape_yahoo('GC=F'),
62 scrape_yahoo('^DJI')]
63 return map(pd.Series.rename, out, ['Total Cases', 'Bitcoin', 'Gold', 'Dow Jones'])

Callers 1

scrape_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected