import time, json, requests
from datetime import datetime
import matplotlib.pyplot as plt
url = 'https://view.inews.qq.com/g2/getOnsInfo?name=wuwei_ww_cn_day_counts&callback=&_=%d' % int(time.time() * 1000)
print(url)
data = json.loads(requests.get(url).json()['data'])
data.sort(key=lambda x:x['date'])
print(data)
date_list = []
confirm_list = []
suspect_list = []
dead_list = []
heal_list = []
for item in data:
month,day = item['date'].split('/')
date_list.append(datetime.strptime("2020-%s-%s"%(month,day),"%Y-%m-%d"))
confirm_list.append(int(item['confirm']))
suspect_list.append(int(item['suspect']))
dead_list.append(int(item['dead']))
heal_list.append(int(item['heal']))
print(date_list)
print(confirm_list)
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.plot(date_list,confirm_list)
plt.plot(date_list,suspect_list)
plt.xlabel("时间")
plt.ylabel("确诊人数")
plt.title("新型冠状病毒统计图")
plt.show()
import matplotlib.pyplot as plt
x = []
for i in range(-500,500):
x.append(i)
y = []
for i in x:
y.append(i**37)
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.show()