python 新手,尝试 pip install curl_cffi ,报错:
Could not find a version that satisfies the requirement curl_cffi (from versions: ) No matching distribution found for curl_cffi
python --version 显示:Python 2.7.17
然后尝试 pip3 install curl_cffi ,安装成功了,然后运行 test.py:
from curl_cffi import requests r = requests.get("https://tls.browserleaks.com/json", impersOnate="chrome101") print(r.json())
python3 test.py 报错如下:
Traceback (most recent call last): File "test.py", line 1, in <module> from curl_cffi import requests ImportError: cannot import name 'requests'
python3 --version 显示:Python 3.6.9
请问这该怎么解决?
1 FkingMan 2024-05-08 09:27:58 +08:00 pip3 安装,确认好你的 python 解释器版本。建议安装 pyenv 管理解释器版本 |
![]() | 2 triangle111 2024-05-08 09:28:21 +08:00 python 版本太低了,用 python3.8 以上版本再试一下 |
![]() | 3 linxiaojialin 2024-05-08 09:39:22 +08:00 用这个真的能防盾吗?交流一下 |
4 vaporemix 2024-05-08 09:43:35 +08:00 @linxiaojialin 只能说过不了再想别的法子 |
![]() | 5 Vegetable 2024-05-08 10:20:00 +08:00 你用的 py3.6,pip 安装的这个包可能是非常旧的 0.1.5 版本,这个版本并没有你想要的 requests |
![]() | 6 linxiaojialin 2024-05-08 15:19:21 +08:00 @vaporemix 有试过几种盾,感觉其实它们并不在意指纹,更多的是看 UserAgent 和请求频率,用原生的 requests 和 curl_cffi 效果是一样的。甚至 curl_cffi 还缺少一些功能。 请教一下,你有试过哪种盾,用原生的 requests 会触发,用 curl_cffi 不触发吗? |
![]() | 7 linxiaojialin 2024-05-08 15:24:00 +08:00 @kisshere 解决了吗?这个好像只能在 Python 3.8~3.10 之间安装,建议用 3.9 。版本太低装不了,太高好像跟其它拓展有冲突。 |
![]() | 8 qq78660651 2024-05-08 16:21:28 +08:00 @linxiaojialin #3 https://pypi.org/project/tls-client/ 这个原理应该类似吧,昨天看到的,能过盾 |
![]() | 9 qq78660651 2024-05-08 16:23:29 +08:00 @qq78660651 测试网站 aHR0cHM6Ly9qYWJsZS50di8=; 刚好是你说的这种例子用 requests 能触发盾,但是用这个 tls-client 不会触发; |
![]() | 10 linxiaojialin 2024-05-08 17:00:24 +08:00 @qq78660651 感谢,我试试看 |
![]() | 11 awsl2333 2024-05-09 02:38:48 +08:00 via Android pip 和 python 的对应很乱,尤其是存在多个版本或者使用虚拟环境的时候,建议全部使用 python3 -m pip 的方式,此处 python3 可以是绝对路径或者相对路径 |
12 julyclyde 2024-05-13 13:10:22 +08:00 我去看了一下文档才明白原来 curl_cffi 提供了和 requests 一样的接口 |