当前位置:网站首页>06 JSON string for extracting data
06 JSON string for extracting data
2022-07-21 19:10:00 【Yinma Hanhai】
# 1. Import related modules
import re
import requests
from bs4 import BeautifulSoup
# 2. Send a request , Get the first page of the epidemic
response = requests.get('https://ncov.dxy.cn/ncovh5/view/pneumonia')
home_page = response.content.decode()
# 3. Use BeautifulSoup Extract epidemic data
soup = BeautifulSoup(home_page, 'lxml')
script = soup.find(id="getListByCountryTypeService2true")
# print(script) # It's straight here script Just go , You can print out all the contents
# 4. Using regular expressions , extract json character string
json_str = re.findall(r'\[.+\]', script.string)[0]
print(json_str)
边栏推荐
- The thought of depth first and breadth first
- swift和OC对比,Swift的核心思想:面向协议编程
- Don't be silly to distinguish these kinds of storage volumes of kubernetes
- Protocole TCP
- Powermock actual combat
- 若依框架之swagger接口文档
- 软件测试面试题:黑盒测试和白盒测试是软件测试的两种基本方法,请分别说明各自的优点和缺点!
- Clickhouse architecture
- Hongmeng harmonios deveco studio reported an error unistall_ FAILED_ INTERNAL_ ERROR
- 目前最畅销的 10 个 NFT
猜你喜欢
Flyter icons built-in icon library materialicons Encyclopedia
Tutorial (7.0) 03 Forticlient EMS configuration and Management * forticlient EMS * Fortinet network security expert NSE 5
bryntum gantt 5.0.6
C语言——库函数qsort的使用和模拟实现
Synchronized lock range
Jujube technology CEO's monthly DDC briefing (phase III) -- Introduction to new functions of DDC network and review of essence of Wenchang chain upgrade plan
synchronized锁范围
Oracle export table data -dmp file
目前最畅销的 10 个 NFT
【性能优化】MySQL常用慢查询分析工具
随机推荐
Small exercise of batch replacement with VIM regular expression
[QNX hypervisor 2.2 user manual]8.6 interrupt
Manual implementation of solving single source shortest path
ES 自定义分析器
API Test
Protocole TCP
V853开发板硬件资料——RISC-V核E907用户手册
Don't be silly to distinguish these kinds of storage volumes of kubernetes
V853 development board hardware data - risc-v core e907 user manual
知识图谱问答技术实践与探索
软件测试面试题:如何测试一个纸杯?
PyTorch 深度学习实践 第2讲/作业(Linear Model)
[pytoch] learning notes (I) create your own data set
C language type conversion
阿里云发布行业首个「视频直播技术最佳实践图」!
[QT] correct method of character encoding conversion of log path
软件测试面试题:Internet采用哪种网络协议?该协议的主要层次结构?Internet物理地址和IP地址转换采用什么协议?
C language constants and variables
数据分析常见的业务面试题
Unity—Input类