本帖最后由 lihu5841314 于 2021-6-27 15:40 编辑
[Asm] 纯文本查看 复制代码 import requests,re
start_url = 'https://www.jijikb.com/play/52360-0-0.html'
headers ={
'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',
'Connection': 'keep-alive',
'Host': 'www.jijikb.com',
'Pragma': 'no-cache',
'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
'sec-ch-ua-mobile': '?0',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36',
}
"""
请求响应码 403
1、开了Filder之类的抓包工具;
2、使用了ip代{过}{滤}理。
解决:
1.关闭抓包工具;
2.在请求参数中设置代{过}{滤}理为(verify= False):
"""
try:
start_response = requests.get(url=start_url,headers=headers,timeout =20,verify = False)
start_response.encoding = start_response.apparent_encoding
print(start_response.status_code)
start_response = start_response.text
print(start_response)
#以下其他运行代码...
except requests.exceptions.ConnectionError:
r.status_code = "Connection refused" |