我正在尝试使用 Python 的 liburl2 访问此处记录的 Dreamhost API:http://wiki.dreamhost.com/API
这是我的代码:
request = urllib2.Request('https://api.dreamhost.com/?key=<key>')
response = urllib2.urlopen(request)
page = response.read()
print(page)
这总是失败并出现错误:
urllib2.URLError: <urlopen error [Errno 104] Connection reset by peer>
我完全被难住了,因为我可以正常 ping api.dreamhost.com,并且 wget https://api.dreamhost.com/?key=也能正常工作。
有什么想法吗?
请您参考如下方法:
我知道这是一个老问题,但我遇到了同样的问题,并通过另外两个问题找到了解决方案。
这表明问题出在使用 SSLv3 的握手上:
OpenSSL issues in Debian Wheezy
这给出了一些可能的解决方案:
Python HTTPS requests (urllib2) to some sites fail on Ubuntu 12.04 without proxy
