题目标题已经很明显了,Http2.0
数据接口
对应的请求协议也为 http2.0
python 代码
import httpx # pip install httpx
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
}
cookies = {
"sessionid": "你的sessionId",
}
# 获取 http2 的支持
# pip install httpx[http2]
requests = httpx.Client(http2=True, headers=headers, cookies=cookies) # 开启 http2 请求
def send_match17(page_):
url = "https://match.yuanrenxue.cn/api/match/17"
params = {
"page": f"{page_}"
}
response = requests.get(url, headers=headers, cookies=cookies, params=params)
print(response.json())
return response.json()['data']
if __name__ == '__main__':
nums = 0
for page in range(1, 6):
nums_list = send_match17(page)
for num in nums_list:
nums += num['value']
print('page: ', page, 'nums: ', nums)