我正在使用 httplib2 发出请求,但出现以下错误
[Errno 104] Connection reset by peer
这就是我在代码中实现它的方式
import httplib2
timeout = 60
h = httplib2.Http(".cache", timeout=timeout, disable_ssl_certificate_validation=True)
h.request('https://somewebsite.com/some_xml_page.aspx', "GET")
connect fail: (somewebsite.com, 443)
connect fail: (somewebsite.com, 443)
error Traceback (most recent call last)
<ipython-input-7-c8b901c7fdfa> in <module>()
----> 1 h.request('https://somewebsite.com/some_xml_page.aspx', "GET")
/usr/lib/python2.7/dist-packages/httplib2/__init__.pyc in request(self, uri, method, body, headers, redirections, connection_type)
1594 content = ""
1595 else:
-> 1596 (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
1597 except Exception, e:
1598 if self.force_exception_to_status_code:
/usr/lib/python2.7/dist-packages/httplib2/__init__.pyc in _request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey)
1342 auth.request(method, request_uri, headers, body)
1343
-> 1344 (response, content) = self._conn_request(conn, request_uri, method, body, headers)
1345
1346 if auth:
/usr/lib/python2.7/dist-packages/httplib2/__init__.pyc in _conn_request(self, conn, request_uri, method, body, headers)
1316 if i < RETRIES-1:
1317 conn.close()
-> 1318 conn.connect()
1319 continue
1320 else:
/usr/lib/python2.7/dist-packages/httplib2/__init__.pyc in connect(self)
1049 break
1050 if not self.sock:
-> 1051 raise socket.error, msg
1052
1053 SCHEME_TO_CONNECTION = {
error: [Errno 104] Connection reset by peer
我要从中获取页面的服务器具有 TSL 1.1/1.2,但它不支持 SSL v3 SSL v2 和 TLS 1.0。
当我提出请求时,我的代码有效
h.request('https://encrypted.google.com', "GET")
https://encrypted.google.com支持 SSL v3。
如何从具有 TLS 1.1/1.2 协议且没有 SSL v3、SSL v2 和 TLS 1.0 的 Web 服务器获取页面。