解决Python3 控制台输出InsecureRequestWarning的问题

Python爬虫遇到InsecureRequestWarning别慌,这3种处理requests证书警告的方法最稳妥 本文详细解析了Python爬虫中遇到InsecureRequestWarning警告的3种专业解决方案,包括临时禁用警告、全局配置修改和自定义证书验证。针对HTTPS请求中的证书验证问题,提供了从开发调试到生产环境的安全处理建议,帮助开发者平衡效率与安全性。 阅读详情

问题:

使用Python3 requests发送HTTPS请求,已经关闭认证(verify=False)情况下,控制台会输出以下错误:

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

解决方法:

在代码中添加以下代码即可解决:

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

Python2添加如下代码即可解决:

from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

在语句前加入一下代码也可以:

import requests
requests.packages.urllib3.disable_warnings()

参考:
https://www.cnblogs.com/ernana/p/8601789.html
https://blog.youkuaiyun.com/weixin_39461487/article/details/81132922

PCIe链路均衡实战:从Preset调节到系数优化的完整指南(附Synopsy IP案例) 本文深入解析PCIe链路均衡技术,从Preset调节到系数优化的全流程实战指南,特别针对PCIe 3.0/4.0中的Recovery.Equalization状态进行详细说明。通过Synopsy IP案例,展示如何应对高速信号完整性挑战,优化前向反馈均衡(FFE)机制,提升系统性能。 阅读详情

相关推荐

移远EC21/EC200模组休眠功耗从13mA降到6mA,我排查了这3个坑(附完整AT指令流程)

本文详细介绍了移远EC21/EC200模组休眠功耗从13mA优化至6mA的完整解决方案,涵盖硬件设计检查、AT指令配置、RTOS调度优化和固件兼容性验证等关键步骤。通过系统性的低功耗问题诊断框架,帮助IoT设备开发者有效提升电池续航能力,特别适合智能水表等电池供电场景应用。

weixin_30715523的博客 534

requests模块之InsecureRequestWarning警告

解决问题: requests请求出现警告: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. 解决步骤: 1、加入verify=False参数: 具体如: response = requests.get(url=ur...

zhaojiafu的博客 3281

vc mfc listctrl使用虚拟列表 虚拟列表用法

note 虚拟列表可有效加载大量数据 需要处理listctrl的 LVN_GETDISPINFO 消息 使用虚拟列表 不能 使用 insert的方法插入数据,而是告诉listctrl 当前要显示多少行 使用SetItemCount函数告诉listctrl当前显示多少行 使用虚拟列表需要自己维护数据源 使用 添加list ctrl 控件 将其Owner Data 属性 设置为 True 添加...

知其所以然 398

python:关于处理requests弹出来的警告,加上这两句代码就好了

平时我们写爬虫时,一定会遇到证书的问题的,在requests.get()的时候加上忽略验证证书就好了,在requests.get(verify=Flase)加上去,但运行后会发现有警告,如下图   虽然不影响代码的运行,但实在是不太美观,所以加上这两句代码吧 from requests.packages.urllib3.exceptions import InsecureRequest...

一位不愿透露姓名的雷锋 2168

告别概念晕眩:用TC3xx SMU和TLF35584的配置实例,搞懂ASIL D功能安全落地

本文通过英飞凌TC3xx系列MCU的SMU模块与TLF35584电源管理芯片的协同配置实例,详细解析了如何实现符合ASIL D功能安全标准的刹车辅助ECU。文章涵盖SMU报警源配置、响应动作类型、TLF35584的安全状态管理,以及构建完整安全闭环的实践方法,帮助工程师将抽象的安全概念落地为具体设计方案。

weixin_30647065的博客 437

Graylog日志系统实战:高效接收与解析交换机日志

本文提供Graylog日志系统的实战部署与配置指南,重点讲解如何高效接收与解析交换机日志。通过Docker快速部署,配置Syslog输入,并指导华为、华三等主流交换机将日志发送至Graylog。文章还介绍了使用提取器解析日志字段、创建数据流进行分类,以及设置报警规则,实现从被动排查到主动预警的运维转变,帮助网络工程师构建集中、智能的日志管理系统。

weixin_29284885的博客 540

Python屏蔽InsecureRequestWarning报错

使用Python3 requests发送HTTPS请求,在关闭SSL认证(verify=False)的情况下: import requests response = requests.get(url='http://127.0.0.1:12345/test', verify=False) 会出现如下错误: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification i

Watson_R的博客 4678

异步处理优化:多线程线程池与消息队列的选择与应用

本文讨论了两种常见的异步处理方式:多线程线程池和消息队列(MQ)。通过将非核心逻辑异步化,可以提升系统的性能和响应速度。多线程线程池适用于本地并发任务,适合需要快速响应的场景,但无法处理跨服务任务。消息队列则适用于分布式系统,能够解耦服务并保证任务的可靠性和顺序性,适合处理高并发和高可靠性要求的任务。文章提供了实际代码示例,帮助开发者根据业务需求选择合适的异步处理方式。

曾经“等你生日那天”都遥远得像未来,如今却可欢愉的挥手说“下个十年见” 170万+

解决: python requests输出InsecureRequestWarning

转自原文: https://www.cnblogs.com/ernana/p/8601789.html python3 import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) python2 from requests.packages.urllib3.exceptions import...

招财进宝 1309

置顶必读(3) |《滚雪球学SpringBoot》· 高质量专栏介绍,你值得拥有!

《滚雪球学SpringBoot》 并不是普通的技术讲解合集,它是专为开发者精心设计的系统化学习路径。通过不断“滚动学习”,我们将带领你从基础入门到高阶应用,从理解每一行代码到设计和优化大规模分布式系统,最终帮助你成长为一位精通 spring架构 的工程师。

**My Coding Family** 15万+

Coze实战:解锁多Bot协同与条件分支工作流的奥秘

本文详细介绍了在字节跳动Coze平台实现多Bot协同与条件分支工作流的方法。首先阐述了Coze平台的功能优势,包括丰富的插件、知识库和工作流功能。随后分步骤讲解了多Bot协同的实现:从准备工作、创建Bot到协同配置,并提供了电商客服的实例演示。在条件分支工作流部分,详细说明了条件节点的作用类型、条件设定方法以及具体配置操作,强调测试优化的重要性。最后通过电商平台综合案例,展示了多Bot协同与条件分支的实际应用效果,并针对常见问题提供解决方案。文章为开发者在Coze平台上构建智能应用提供了实用指导,有助于提升

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 450

python 使用requests请求https输出警报InsecureRequestWarning

报错  Python Requests throwing up SSLError 解决方法: verify=False requests.put(url,data = data, headers=headers, timeout=10, verify=False) requests.get(url,data = data, headers=headers, timeout=10, ver...

Ren_ger的博客 1139

利用 Python 爬虫进行舆情监测的实战方法

舆情监测是指对互联网上的公众舆论进行监测和分析的过程。它可以帮助企业和组织了解公众对其品牌、产品或服务的看法,以及市场竞争情况。通过舆情监测,企业可以及时发现潜在的问题和机会,从而做出相应的决策。通过本实战案例,我们了解了如何利用 Python 爬虫进行舆情监测的整个流程。从数据采集到数据分析,再到可视化展示,每一步都提供了详细的代码示例和注释。希望这些方法和技巧能够帮助你在实际工作中更好地进行舆情监测,从而为企业的决策提供有力的支持。wordcloud。

u014481728的博客 1054

Python requests 移除SSL认证,verify=False,取消控制台输出的InsecureRequestWarning警告

在Python3中使用以下代码报错: import requests response = requests.get(url='', verify=False) 错误代码如下: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly ad...

May女子の博客 3万+

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

解决Python3 爬虫InsecureRequestWarning的问题

问题: 使用Python3 requests发送HTTPS请求,已经关闭认证(verify=False)情况下,控制台会输出以下错误: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-w

阿拉修 1025

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Python requests 移除SSL认证,控制台输出InsecureRequestWarning取消方法。

今天遇到在requests设置移除SSL认证的时候,控制台会抛出以下警告:C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py:843: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate ve

xie_0723的博客 4万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

解决Python3 HTTPS请求时InsecureRequestWarning的问题

使用Python3 requests发送HTTPS请求,已经关闭认证(verify=False)情况下,控制台会输出以下错误: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warni

mz02230909mz的博客 597

Python3出现InsecureRequestWarning

使用Python3requests发送HTTPS请求,已经关闭认证(verify=False)情况下,控制台会输出以下错误: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urlli...

zhangvalue的博客 704

requests出现InsecureRequestWarning解决

问题: 使用Python3requests发送HTTPS请求,已经关闭认证(verify=False)情况下,控制台会输出以下warning: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: htt...

夜莺_Cody 8655

Python requests解决打开抓包工具也能运行自动化脚本,及取消控制台输出的InsecureRequestWarning警告

  在运行Python+requests+pytest接口自动化脚本时,如打开了抓包工具,会报错:HTTPSConnectionPool(x):Max retries(Caused by SSLError)。   其中最简单的解决方案就是关闭抓包工具,当然还有使用代码移除SSL认证,实现方式为: import requests response = requests.get(url='', verify=False)   使用requests设置移除SSL认证的时候,运行用例后控制台会报以下警告: 虽然

adorable_的博客 860

Python中出现InsecureRequestWarning警告如何忽略?

摘要:Python使用requests包发起请求时若设置verify=False参数,控制台会输出安全警告干扰日志查看。解决方法是在代码文件头部添加两行代码:先导入urllib3模块,然后调用urllib3.disable_warnings()方法禁用InsecureRequestWarning警告,即可消除控制台的不必要警告信息。

students33的博客 461
上一篇: python字符串与列表的相互转换
下一篇: 两个或者三个以上列表和字符串的相加拼接
hellenlee22
博客等级 码龄9年 70粉丝 66原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值