Loading... ## 报错信息 > **curl_cffi.requests.errors.RequestsError: Failed to perform, curl: (35) Recv failure: Connection reset by peer. See https://curl.se/libcurl/c/libcurl-errors.html first for more details.** ## 环境 电脑:mac M3 pychrom: 2024最新专业版 python :3.10 ## 遇到的问题 浏览器可以正常访问网站,请求接口没有加密参数,也没有cookie加密,但是pychrom无法请求成功发现有指纹校验,先使用`curl_cffi`库,也失败了,终端也没法请求成功,切报错一致,排除了(vpn,hosts,连接的wifi或宽带,openssl)等问题 ## 解决办法 报错里面有[链接](https://curl.se/libcurl/c/libcurl-errors.html)和报错代号`(35)`,点进去发现是ssl,那就走走代理把,本地环境可能有啥毛病 打开`clashx`,然后请求代码加入`proxies = { "http": "http://127.0.0.1:7890", "https": "http://127.0.0.1:7890"}`再去访问,Success!!!!  ## 完整代码 ```python from curl_cffi import requests from lxml import etree #这个网站有指纹认证 proxies = { "http": "http://127.0.0.1:7890", "https": "http://127.0.0.1:7890", } # 请求头 headers= { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36', 'Cookie': 'PHPSESSID=3cc8a806ef', 'Host': 'www.qiufengshuwu.com', # 'Connection': 'keep-alive' } # 当前页面链接 url = 'https://www.qiufengshuwu.com/4/4625/734603.html' #增加指纹 # resp = requests.get(url, headers, impersonate="chrome101",proxies=proxies) resp = requests.get(url, headers, impersonate="chrome101") text = resp.content.decode('gbk') print(text) ``` 最后修改:2024 年 09 月 19 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 1 如果觉得我的文章对你有用,请随意赞赏