利用几行python代码爬取全国疫情数据,全方位地图分析疫情地区分布

全球疫情数据爬取与可视化

爬取全国疫情数据

所用的网页连接: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   #自己写的代码模块 导入

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黎明之道

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值