text_html_output_1.png
from datetime import datetime

import datetime

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pandas_datareader.data as web

import time

import yfinance as yf

ticker = 'SPY'
start_time = datetime(2020, 5, 1)
end_time = datetime(2023, 5, 1)
spy = yf.download(ticker, start=start_time, end=end_time)

connected = False
while not connected:
    try:
        ticker_df = web.get_data_yahoo(ticker, start=start_time, end=end_time)
        connected = True
        print('connected to yahoo')
    except Exception as e:
        print('type error: ' + str(e))
        time.sleep(5)
        pass
ticker_df = ticker_df.reset_index()
df = pd.DataFrame(ticker_df)
print(ticker_df)