将表的原始json数据读入df表?

我正在尝试将 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)


慕桂英3389331
浏览 120回答 1
1回答

拉风的咖菲猫

使用给定的 URL。import pandas as pdimport requestsurl="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)它正在工作,请参阅下面的屏幕截图
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python