执笔墨飘烟
2021-03-23 20:29
采纳率: 100%
浏览 133
已采纳

requests无法发送HTTPS请求

http能发送,https秒报错(所有网站),网上的方法都尝试过了。

操作系统:linux

Windows上可运行,linux不可,python版本号一致:3.8.8

尝试过的方法:

1. 加上verify=False

2. 下载各种依赖包

3. 更新ca-certificates

4. 使用requests.packages.urllib3.disable_warnings()

错误信息:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    rep = requests.get('https://www.google.com/', verify=False)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))
源码:

import requests


rep = requests.get('https://www.google.com/', verify=False)
print(rep.text)
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • liqiang94 2021-03-24 09:44
    最佳回答

    我之前遇到过这样的问题,是通过更新openssl解决的,你可以试试。

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题