Python request设置HTTPS代理代码解析
作者:sysu_lluozh 时间:2023-01-15 00:48:24
之前版本的代理中,可以使用fiddler进行HTTP包的代理,但是代理HTTPS包时,执行错误
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)
urllib或requests在打开https站点是会验证证书,简单的处理方式就是把发送https请求时把验证ssl证书关掉,即设置verify为False
具体代码设置如:
requests.post(host, data=requestData, headers=headerData,proxies=proxies,verify=False)
取消SSL验证又带来一个新问题
C:\Users\lluozh\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
虽然不是错误,但是在捕捉异常时,默认会出问题,为了不影响原有流程,应该去掉这些警告信息
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
或者直接取消所有urllib3的警告
requests.packages.urllib3.disable_warnings()
来源:http://blog.csdn.net/lluozh2015/article/details/78769288
标签:python,request,https
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python深度学习实战PyQt5菜单和工具栏功能作用
2021-04-04 16:09:40
![](https://img.aspxhome.com/file/2023/9/76899_0s.png)
Firefox 的 Jetpack 扩展案例分析:Gmail 邮件提醒
2009-10-15 12:41:00
![](https://img.aspxhome.com/file/UploadPic/200910/15/gmail01-18s.png)
Microsoft SQL Server 安全问题
2010-07-26 13:20:00
Python机器学习之决策树
2022-02-24 07:19:01
![](https://img.aspxhome.com/file/2023/6/79416_0s.png)
python实现图像拼接
2023-07-26 15:38:27
![](https://img.aspxhome.com/file/2023/9/60969_0s.jpg)
PHP中isset()和unset()函数的用法小结
2023-11-19 14:19:24
Flume监听oracle表增量的步骤详解
2023-07-20 00:39:32
Python有序查找算法之二分法实例分析
2023-04-09 00:02:37
![](https://img.aspxhome.com/file/2023/8/85378_0s.jpg)
Python中try excpet BaseException(异常处理捕获)的使用
2023-07-30 16:21:37
![](https://img.aspxhome.com/file/2023/0/71520_0s.png)
如何编写高质量的Javascript代码
2011-03-07 16:04:00
Oracle 8i字符集乱码问题析及其解决办法
2010-07-26 13:29:00
java正则表达式之Pattern与Matcher类详解
2023-06-21 10:14:03
![](https://img.aspxhome.com/file/2023/2/58592_0s.png)
python 批量修改 labelImg 生成的xml文件的方法
2022-09-03 12:04:23
pytorch显存一直变大的解决方案
2021-03-03 00:03:09
python中管道用法入门实例
2022-06-26 21:42:08
数据库查询的分页优化技巧
2009-05-17 10:31:00
go slice 数组和切片使用区别示例解析
2023-06-22 04:07:16
![](https://img.aspxhome.com/file/2023/0/87610_0s.jpg)
深入理解Django的自定义过滤器
2021-01-25 04:01:54
![](https://img.aspxhome.com/file/2023/1/71421_0s.jpg)
django API 中接口的互相调用实例
2023-11-04 09:36:38
python基础之迭代器与生成器
2022-02-20 07:07:54