python抓图源码 python抓包https

您所在的位置:网站首页 Python如何关闭ssl认证 python抓图源码 python抓包https

python抓图源码 python抓包https

2023-05-27 22:00| 来源: 网络整理| 查看: 265

电脑环境

python:3.7

requests:2.22.0

fiddler:v5.0.20

python抓图源码 python抓包https_python

 

python抓图源码 python抓包https_python_02

 

 一、SSL问题

1.在你不启用fiddler时,python代码直接发送https请求,不会有SSL问题(也就是说不想看到SSL问题,关掉fiddler就行)

python抓图源码 python抓包https_python_03

 

 2.启动fiddler抓包,会出现SSLError这个错误:

requests.exceptions.SSLError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

python抓图源码 python抓包https_Max_04

 

 解决办法:

一、verify参数设置

  1.Requests的请求默认verify=True

  2.如果你将verify设置为False,Requests也能忽略对SSL证书的验证

  3.但是依然会出现两行Warning,可以不用管

python抓图源码 python抓包https_Max_05

 

 二、忽略Warning

Python3添加如下三种任意一种代码即可解决;

import requests import warnings #warnings.filterwarnings("ignore") #方式1 #requests.packages.urllib3.disable_warnings()#方式2 import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)#方式3 r=requests.get("https://www.baidu.com",verify=False) print(r.status_code)

  

  

 



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3