如何使用 urllib2 获取使用 SSLv3 加密的网页 [英] How to use urllib2 to get a webpage using SSLv3 encryption

查看:34
本文介绍了如何使用 urllib2 获取使用 SSLv3 加密的网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 python 2.7,我想获取需要 sslv3 的网页的内容.目前,当我尝试访问该页面时,出现错误 SSL23_GET_SERVER_HELLO,并且在网络上进行了一些搜索,找到了以下解决方案,该解决方案修复了 Python 3 中的问题

I'm using python 2.7 and I'd like to get the contents of a webpage that requires sslv3. Currently when I try to access the page I get the error SSL23_GET_SERVER_HELLO, and some searching on the web lead me to the following solution which fixes things in Python 3

urllib.request.install_opener(urllib.request.build_opener(urllib.request.HTTPSHandler(context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))))

如何在 python 2.7 中获得相同的效果,因为我似乎找不到 HTTPSHandler 类的上下文参数的等效项.

How can I get the same effect in python 2.7, as I can't seem to find the equivalent of the context argument for the HTTPSHandler class.

推荐答案

由于我无法使用 urllib2 执行此操作,因此我最终屈服并转而使用 libCurl 绑定,就像 @Bruno 在对 Pastylegs 答案的评论中所建议的那样.

Since I was unable to do this using urllib2, I eventually gave in and moved to using the libCurl bindings like @Bruno had suggested in the comments to pastylegs answer.

这篇关于如何使用 urllib2 获取使用 SSLv3 加密的网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆