Python常见问题 - python3 使用requests发送HTTPS请求报certificate verify failed 错误

简介: Python常见问题 - python3 使用requests发送HTTPS请求报certificate verify failed 错误

当你使用 requests 发送HTTPS请求时


requests.get(url, parmas=parmas, headers=header, cookies=cookie)

出现了以下错误

HTTPSConnectionPool(host='www.imooc.com', port=443): Max retries exceeded with url: /api3/getbanneradvertver2 (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)'),))

 

出现原因


当你发送HTTPS请求时,需要SSL验证,而requests请求方法的 verify 参数默认是 True ,表示要进行验证

 

如何解决?


关掉验证即可,如下

requests.get(url, parmas=parmas, headers=header, cookies=cookie, verify=False)

相关文章
|
19天前
|
NoSQL MongoDB Python
【Python】已完美解决(MongoDB安装报错)Service ‘MongoDB Server (MongoDB)’ (MongoDB) failed tostart
【Python】已完美解决(MongoDB安装报错)Service ‘MongoDB Server (MongoDB)’ (MongoDB) failed tostart
25 1
|
2月前
|
数据采集 机器学习/深度学习 人工智能
2024最新版Python安装教程,适合新手,赶快收藏!_python3最新版2024
2024最新版Python安装教程,适合新手,赶快收藏!_python3最新版2024
|
18天前
|
开发者 Python
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
29 0
【Python】已解决:(Python3中pip无法安装urllib报错问题) ERROR: Could not find a version that satisfies the requireme
|
17天前
|
JavaScript 前端开发 Java
python结构化模式匹配switch-case,Python 3.10中引入,Python的模式匹配(pattern matching)语法
python结构化模式匹配switch-case,Python 3.10中引入,Python的模式匹配(pattern matching)语法
Get “https://npm.taobao.org/mirrors/node/latest/SHASUMS256.txt“: tls: failed to verify certificate:
Get “https://npm.taobao.org/mirrors/node/latest/SHASUMS256.txt“: tls: failed to verify certificate:
|
1月前
|
JSON 程序员 数据格式
豆瓣评分9.6!用81个项目带你从Python 3零基础到Python自动化
Python的名字来自超现实主义的英国喜剧团体,而不是来自蛇。Python程序员被亲切地称为Pythonistas。Monty Python和与蛇相关的引用常常出现在Python的指南和文档中。
|
1月前
|
JSON 程序员 数据格式
豆瓣评分9.6!用81个项目带你从Python 3零基础到Python自动化
Python的名字来自超现实主义的英国喜剧团体,而不是来自蛇。Python程序员被亲切地称为Pythonistas。Monty Python和与蛇相关的引用常常出现在Python的指南和文档中。
|
2月前
|
数据采集 SQL 数据挖掘
2024最新版Python安装教程,适合新手,赶快收藏!_python3最新版2024(1)
2024最新版Python安装教程,适合新手,赶快收藏!_python3最新版2024(1)
|
2月前
|
数据采集 数据挖掘 Python
[Github高赞文章]python2愉快地迁移到Python3_code changing from python2 to python3(2)
[Github高赞文章]python2愉快地迁移到Python3_code changing from python2 to python3(2)
|
2月前
|
数据采集 机器学习/深度学习 人工智能
2024最新版Python安装教程,适合新手,赶快收藏!_python3最新版2024(3)
2024最新版Python安装教程,适合新手,赶快收藏!_python3最新版2024(3)