爬取全国疫情数据
所用的网页连接:https://api.inews.qq.com/newsqa/v1/automation/foreign/country/ranklist
可视化用到的模块:——>戳这里下载,也可以看最后,或私信我
如果没有模块的可自行下载:pip install 模块 命令下载
先看下整体效果图:

先导入库:
import requests #导入第三方库
import json # 轻量级的数据交互格式
测试网站:
url='https://api.inews.qq.com/newsqa/v1/automation/foreign/country/ranklist'
resp = requests.post(url) #get post 对网址post请求
print(resp) #字符串


查看数据类型:字典。

1。提取国家名字 病死率数量
#爬取全国疫情数据
url='https://api.inews.qq.com/newsqa/v1/automation/foreign/country/ranklist'
resp = requests.post(url).text #get post 对网址post请求
# print(resp) #字符串
2. 提取病死率数量
#病死率数量
confirm=jsonpath.jsonpath(data,"$..confirm") #提取数据
print(confirm)
3. 整理数据 `
# 整理数据 zip
a = zip(name,confirm)
print(a)

可视化地图分析
先导入库
from pyexpats.charts import Map #地图matplotlib :静态图
from pyexpats import options as opts #配置项
from demol import nameMap #自己写的代码模块 导入
全球疫情数据爬取与可视化

最低0.47元/天 解锁文章
1021

被折叠的 条评论
为什么被折叠?



