今天腾讯更新了url以及数据的数据结构,上代码
import json
import requests
url = '
https://view.inews.qq.com/g2/getOnsInfo?name=disease_h5&callback'res = requests.get(url).json()['data']
data = json.loads(res)
def showupdatetime(data):
print(str(data['lastUpdateTime']))
def showeverycity(data):
list0 = data['areaTree']
list1 = list0[0]
list2 = list1['children']
for province in list2:
templist = province['children']
print(province['name'] + "省详情:")
for item in templist:
print(str(item['name']) + "累计确诊:" + str(item['total']['confirm']) + "例,疑似:" + str(item['total']['suspect'])+ "例,死亡:"+str(item['total']['dead']) + "例,治愈:"+str(item['total']['heal'])+"例;")
showupdatetime(data)
showeverycity(data)
--
FROM 117.136.53.*