You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.9 KiB
45 lines
1.9 KiB
# QDASDWASD
|
|
import requests
|
|
import csv
|
|
|
|
url1 = 'https://api.inews.qq.com/newsqa/v1/automation/modules/list?modules=FAutoCountryConfirmAdd,WomWorld,WomAboard'
|
|
response1 = requests.post(url1)
|
|
|
|
# 检查请求是否成功
|
|
if response1.status_code == 200:
|
|
json_data1 = response1.json()
|
|
WomAboard = json_data1['data']['WomAboard']
|
|
for wom in WomAboard:
|
|
name = wom['name'] # 国家名称
|
|
confirm = wom['confirm'] # 确诊人数
|
|
confirmAdd = wom['confirmAdd'] # 新增人数
|
|
dead = wom['dead'] # 死亡人数
|
|
heal = wom['heal'] # 治愈人数
|
|
nowConfirm = wom['nowConfirm'] # 现有确诊
|
|
print(name, confirm, confirmAdd, dead, heal, nowConfirm)
|
|
with open('疫情数据1.csv', mode='a', encoding='utf-8', newline='') as f:
|
|
csv_writer = csv.writer(f) # 创建 csv_writer 对象
|
|
csv_writer.writerow([name, confirm, confirmAdd, dead, heal, nowConfirm]) # 写入数据行
|
|
else:
|
|
print("API请求失败或者没有返回数据")
|
|
|
|
url2 = 'https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=localCityNCOVDataList,diseaseh5Shelf'
|
|
response2 = requests.post(url2)
|
|
|
|
# 检查请求是否成功
|
|
if response2.status_code == 200:
|
|
json_data2 = response2.json()
|
|
chinaTotal = json_data2['data']['diseaseh5Shelf']['chinaTotal']
|
|
confirm = chinaTotal['confirm']
|
|
confirmAdd = chinaTotal['confirmAdd']
|
|
dead = chinaTotal['dead']
|
|
heal = chinaTotal['heal']
|
|
nowConfirm = chinaTotal['nowConfirm']
|
|
name = "国内"
|
|
print(name, confirm, confirmAdd, dead, heal, nowConfirm)
|
|
with open('疫情数据1.csv', mode='a', encoding='utf-8', newline='') as f:
|
|
csv_writer = csv.writer(f) # 创建 csv_writer 对象
|
|
csv_writer.writerow([name, confirm, confirmAdd, dead, heal, nowConfirm]) # 写入数据行
|
|
else:
|
|
print("API请求失败或者没有返回数据")
|