当我在http://www.google.com上运行以下示例代码时,它可以正常工作。但是当我尝试在https://www.google.com上运行时,我会收到以下错误信息:
Requesting https://www.google.com
Unhandled error in Deferred:
Unhandled Error
Traceback (most recent call last):
Failure: twisted.web._newclient.ResponseNeverReceived: [<twisted.python.failure.Failure <class 'OpenSSL.SSL.Error'>>]
我正在使用Python 2.7.8、Twisted 14.0.2、Service_identity 14.0.0、Treq 0.2.1和OpenSSL 0.14。
import treq
from twisted.internet import reactor, defer
import sys
@defer.inlineCallbacks
def doit(url):
print "Requesting "+ url + "\n"
results = yield treq.get(url)
print "...got results\n"
content = yield results.content()
print "%s"%content
reactor.stop()
def main():
url = sys.argv[1]
reactor.callLater(0, doit, url)
reactor.run()
if __name__ == '__main__':
main()
提前感谢您!