代码如下:(相关Cookies已删)
import json
import requests
headerTemplate = {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
"cookie": "cookie已清除",
"pragma": "no-cache",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"
}
res = json.loads(requests.get('https://api.bilibili.com/x/web-interface/nav',headers = headerTemplate).text)
print(res)
运行后报错:
{'code': -412, 'message': '请求被拦截', 'ttl': 1, 'data': None}
问问为什么会报-412错误啊