import requests
import json
from bs4 import BeautifulSoup
# 设置请求头,模拟浏览器访问
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}
# 发送请求,获取网页内容
url = 'https://crediths-gov.com/data/list.json?_=11111'
response = requests.get(url, headers=headers)
# #设置字符集
# response.encoding = "UTF-8"
# # 解析网页内容
# soup = BeautifulSoup(response.text, 'html.parser')
data = json.loads(response.text)
contentList = data.get("list")
#print(contentList)
for content in contentList:
print(content.get("ename"), "\t", content.get("egrade"), "\t", \
content.get("cerno"), content.get("idate"))
python爬取异步请求的数据
最新推荐文章于 2024-03-31 23:26:58 发布