可以使用
Python的Requests和BeautifulSoup库来
爬取新冠疫情数据。以下是一个简单的示例:
```
python
im
port requests
from bs4 im
port BeautifulSoup
url = "https://ncov.dxy.cn/ncovh5/view/pneumonia"
respo
nse = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
# 获取国内
疫情数据
china_data = soup.find("s
cript", attrs={"id": "getAreaStat"}).string
china_data = china_data.replace("try { window.getAreaStat =", "")[:-1]
china_data = json.loads(china_data)
# 获取全球
疫情数据
global_data = soup.find("s
cript", attrs={"id": "getListByCountryTypeService2"}).string
global_data = global_data.replace("try { window.getListByCountryTypeService2true = ", "")[:-1]
global_data = json.loads(global_data)
# 打印
疫情数据
print("国内
疫情数据:", china_data)
print("全球
疫情数据:", global_data)