• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > 解决Python requests 报错方法集锦

解决Python requests 报错方法集锦

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python requests,python requests模块,python requests下载,python requests安装,python requests库等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

python版本和ssl版本都会导致 requests在请求https网站时候会出一些错误,最好使用新版本。

1 Python2.6x use requests

一台老Centos机器上跑着古老的应用,加了一个新模块之后报错 报错 InsecurePlatformWarning: A true SSLContext object is not available.

/usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py:132: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning

解决办法

使用老版本的 requests

$pip install requests==2.5.3
</div>

或者这样安装

$ pip install requests[security]
</div>

2 SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

错误如下 版本 python2.7.5

Traceback (most recent call last):
  File "./test.py", line 24, in <module>
  response = requests.get(url1, headers=headers)
  File "build/bdist.linux-x86_64/egg/requests/api.py", line 52, in get
  File "build/bdist.linux-x86_64/egg/requests/api.py", line 40, in request
  File "build/bdist.linux-x86_64/egg/requests/sessions.py", line 209, in request
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 624, in send
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 300, in _build_response
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 611, in send
requests.exceptions.SSLError: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

解决方法

可以禁用 verify

>>> requests.get('https://google.com', verify=True)
问题地址 python-requests-throwing-up-sslerror

3 SSLError: bad handshake

SSLError: bad handshake: Error([(‘SSL routines', ‘SSL3_GET_SERVER_CERTIFICATE', ‘certificate verify failed')],) python2.7.5
pip uninstall -y certifi && pip install certifi==2015.04.28

讨论参见: https://github.com/rackspace/pyrax/issues/601

以上所述是小编给大家介绍的Python requests 报错方法集锦,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

</div>

您可能想查找下面的文章:

  • python中requests小技巧
  • 解决Python requests 报错方法集锦
  • Python中第三方库Requests库的高级用法详解
  • win与linux系统中python requests 安装
  • Python的requests网络编程包使用教程
  • Python的requests网络编程包使用教程
  • Python使用lxml模块和Requests模块抓取HTML页面的教程
  • Python3使用requests发闪存的方法
  • Python3使用requests登录人人影视网站的方法
  • Python Requests安装与简单运用

相关文章

  • Python使用ntplib库同步校准当地时间的方法
  • python实现计算倒数的方法
  • Python and、or以及and-or语法总结
  • 举例讲解Python中is和id的用法
  • TensorFlow实现打印每一层的输出
  • python基础教程之自定义函数介绍
  • python 与GO中操作slice,list的方式实例代码
  • 把项目从Python2.x移植到Python3.x的经验总结
  • 完美解决Python2操作中文名文件乱码的问题
  • 使用Python中的cookielib模拟登录网站

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python实现TCP服务器端与客户端的方法详解
    • python中requests模块的使用方法
    • python获取目录下所有文件的方法
    • Python爬取qq music中的音乐url及批量下载
    • 详解Django中的权限和组以及消息
    • tensorflow实现在函数中用tf.Print输出中间值
    • 使用Protocol Buffers的C语言拓展提速Python程序的示例
    • 详解Python网络爬虫功能的基本写法
    • Python中实现两个字典(dict)合并的方法
    • Python 常用的安装Module方式汇总

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有