Python请求使用代理连接抛出SSLError错误握手

时间:2019-04-15 12:25:07

标签: python ssl proxy

在Python请求模块中,使用代理连接来浏览某些URL

我在https_proxy和http_proxy环境变量中添加了代理ip和端口,以将流量路由到代理

import os
import requests

os.environ["HTTPS_PROXY"] = "proxy1.xx.local:8081"
os.environ["HTTP_PROXY"] = "proxy1xx.local:8081"
H = {"X-Authenticated-User": "bharani@dummy.com"}
url = r"https://google.co.in"
r = requests.get(url,headers=H,verify=False)
print r.status_code
print r.text

我从上述代码中得到的答复

Traceback (most recent call last):
  File "pilot.py", line 356, in <module>
    r = requests.get(url,headers=H,verify=False)
  File "C:\Python27\lib\site-packages\requests\api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 497, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)
还安装了

pyopenssl,ndg-httpsclient,pyasn1。

不确定我要丢失什么。

0 个答案:

没有答案