I am newbie to coding and I am trying to grab some history data from yahoo finance, and the code was work before
def crawl_price(stock_id):
now = int(datetime.datetime.now().timestamp())+86400
url = "https://query1.finance.yahoo.com/v7/finance/download/" + stock_id + "?period1=0&period2=" + str(now) + "&interval=1d&events=history&crumb=hP2rOschxO0"
r = requests.post(url)
f = io.StringIO(r.text)
df = pd.read_csv(f, index_col='Date', parse_dates=['Date'])
conn = sqlite3.connect('data/hkprice.db')
df.to_sql('' + stock_id + '', conn, if_exists='replace')
return df
but the output turns 'Date' is not in list
and i download the csv thought open with pandas, it show perfectly fine
i am not sure what going wrong