python小白一枚,想下載同花順財務報表,股票代碼300033的資產負債表url="http://basic.10jqka.com.cn/api/stock/export.php?export=debt&type=year&code=300033"。按下面代碼做的結果是只新建了空檔案,內容下載不下來,求教?
import requests
code=[]
file_codes = open(r'D:\資料夾\20200506\stockcode.txt')
codes = file_readlines.read().splitlines()
url='http://basic.10jqka.com.cn/api/stock/export.php?export=benefit&type=year&code='
for code in codes:
finance_resport=requests.get(url+str(code)).content
with open("D:\\資料夾\\20200524同花順\\lrb\\{}.csv".format(code),"wb") as f:
f.write(finance_resport)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/40150.html
上一篇:求教python問題:
