我正在尝试将 json 数据从以下位置下载到 df 表中:“ http://emweb.securities.eastmoney.com/NewFinanceAnalysis/lrbAjax?companyType=4&reportDateType=0&reportType=1&endDate=&code=SZ002475 ”,这是原始数据本页底部的表格“ http://emweb.securities.eastmoney.com/NewFinanceAnalysis/Index?type=web&code=SZ002475# ”json 页面似乎是简单的 json 数据,如"[{\"SECURITYCODE\":\"002475.SZ\",\"REPORTTYPE\":\"1\",\"TYPE\":\"4\" ,\"REPORTDATE\":\"2019/9/30 0:00:00\",\"TOTALOPERATEREVE\":\"37836138416.35\",\"OPERATEREVE\":\"37836138416.35\",.... ……”但是,以下代码没有返回任何内容:url ="http://emweb.securities.eastmoney.com/NewFinanceAnalysis/lrbAjax?companyType=4&reportDateType=0&reportType=1&endDate=&code=SZ002475"df = pd.read_json(url) print(df)
1 回答

拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
使用给定的 URL。
import pandas as pd
import requests
url="http://emweb.securities.eastmoney.com/NewFinanceAnalysis/lrbAjax?companyType=4&reportDateType=0&reportType=1&endDate=&code=SZ002475"
json_data = requests.get(url).json()
out_df = pd.DataFrame(eval(json_data))
print(out_df)
它正在工作,请参阅下面的屏幕截图
添加回答
举报
0/150
提交
取消