python问题之requests-packages-urllib3-util-ssl_.py   发布时间:2017-09-11 12:00:58

python问题之requests\packages\urllib3\util\ssl_.py:100: Insecur requests\packages\urllib3\util\ssl_.py:100: InsecurePlatformWarning:

A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html

#insecureplatformwarning.

最近在写一下爬虫,前面用flask和jinja2还有python的mysql连接做了下简单的数据交互的登录验证,比起java的struts这样的控制,确实python来的更加简单。

为什么要用python,一次我用java解密一个东西的时候,半天解不出来,base64写起来也是乱七八糟,到java8自带了。后面用了python尝试了下,两行代码。

使用requests时,访问的是https类型的网址,因为https用了ss加密,会报这种insecureplatformwarning,平台非安全警告,大概与https有关,然后查了下解决办法。

直接警告信息的网址 https://urllib3.readthedocs.org/en/latest/security.html

InsecurePlatformWarning
New in version 1.11.


Certain Python platforms (specifically, versions of Python earlier than 2.7.9) have restrictions in their ssl module that limit the configuration that urllib3 can apply. In particular, this can cause HTTPS requests that would succeed on more featureful platforms to fail, and can cause certain security features to be unavailable.


If you encounter this warning, it is strongly recommended you upgrade to a newer Python version, or that you use pyOpenSSL as described in the OpenSSL / PyOpenSSL section.


在限制urllib3所应用的配置的ssl模块,在某些Python版本(特别是2.7.9之前的)有限制,特别的是,这导致HTTPS请求在本来更多的功能平台成功的变成失败,还有导致某些安全功能模块失效。
如果你遇到这个警告,强烈建议升级到高版本的python版本,或者在OpenSSL/PyOpenSSL部分描述的,你要使用pyOpenSSL。

继续查找了一下解决办法:

https://github.com/plotly/plotly.py/issues/339

按照文章的解决办法,使用$ pip install requests[security] 即可,安装完之后不再有警告。
这个将会安装pyOpenSSL,ndg-httpsclient,pyasn1。


用此命令之前,python环境先要安装pip。pip是安装管理python包的工具。

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:孝感网站制作 http://xiaogan.666rj.com