【发布时间】:2020-09-07 13:40:16
【问题描述】:
我坐在公司代理后面。以下代码不允许我从 HTTPS 站点获取内容。 HTTP 和 HTTPS 代理都通过 HTTP 代理传递。为什么我无法访问该网站?
import requests
url = 'https://www.theguardian.com'
proxies = {
'http': 'http://USERNAME:PASSWORD@IP:PORT',
'https': 'http://USERNAME:PASSWORD@IP:PORT'
}
# Create the session and set the proxies.
s = requests.Session()
s.proxies = proxies
# Make the HTTP request through the session.
r = s.get('https://www.cnbc.com')
r
出现的错误信息是
SSLError: HTTPSConnectionPool(host='www.cnbc.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
【问题讨论】:
-
任何错误信息?你知道你的代码没有输出任何东西吗?
-
@KlausD。请在问题的编辑中找到错误消息
-
询问您的企业 IT 如何通过代理建立 SSL 连接。您可能已经安装或pass 一个特殊的 SSL CA 证书。
-
@KlausD。我已经和我组织中的人交谈过。我已准备好 SSL 证书。它需要使用 get 命令手动注入。这是您以前必须做的事情/知道该怎么做吗?