亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將表的原始json數據讀入df表?

將表的原始json數據讀入df表?

慕桂英3389331 2022-07-26 16:38:08
我正在嘗試將 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)

它正在工作,請參閱下面的屏幕截圖

http://img1.sycdn.imooc.com//62dfa8120001a9dc18200227.jpg

查看完整回答
反對 回復 2022-07-26
  • 1 回答
  • 0 關注
  • 89 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號