def createLIBOR_Rate_CSV():
for LIBOR_Rate_Date_Period, DataId in LIBOR_Rate_Date_Period2DataId.items():
webpageSourceCode = getWebResponseText(f'https://www.macrotrends.net/assets/php/chart_iframe_comp.php?id={DataId}&url=1-month-libor-rate-historical-chart')
originalDataStr = originalDataPtn.search(webpageSourceCode, pos=8000).group(1)
rowDataList = []
for tableRowData in eval(originalDataStr):
rowDataList.append([tableRowData['date'], tableRowData.get('close')]) # 后面这个数据最近几天没有值
# print(rowDataList)
with open(f'./FinancialCharts/static/FinancialCharts/FinancialData/{LIBOR_Rate_Date_Period}.csv', 'w', newline='') as csvfile: # If csvfile is a file object, it should be opened with newline=''
writer = csv.writer(csvfile) # , quoting=csv.QUOTE_NONNUMERIC
writer.writerow(['date', 'close'])
writer.writerows(rowDataList)
macrotrends金融数据抓取
最新推荐文章于 2024-03-23 00:55:44 发布