python requests.exceptions.SSLError

python调接口报错如下:

requests.exceptions.SSLError: HTTPSConnectionPool(host='abc.com', port=443)
Caused by SSLError(SSLError(1, '[SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1123)')))

简单分析了一下原因,最新版本的SSL默认不使用弱DH(DH:即Diffie-Hellman,密钥交换协议/算法),因此会报错。

这里的解决方案是通过设置默认值来降低ssl级别

在需要调度request的文件中引入用一下代码

import requests

requests.packages.urllib3.disable_warnings()
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL'
try:
    requests.packages.urllib3.contrib.pyopenssl.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL'
except AttributeError:
    # no pyopenssl support used / needed / available
    pass

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Learn how to integrate your applications seamlessly with web services using Python Requests About This Book A fast-paced guide that demonstrates the use of Python Requests with the help of examples Learn web scraping with Beautiful Soup and Python Requests libraries Interact with social networking sites such as Facebook, Twitter, and Reddit to retrieve data from them Who This Book Is For If you are a Python administrator or developer interested in interacting with web APIs and have a passion for creating your own web applications, this is the book for you. Basic knowledge of Python programming, APIs, and web services will be an advantage. In Detail Python is one of the most popular programming languages of our era; the Python Requests library is one of the world's best clients, with the highest number of downloads. It allows hassle-free interactions with web applications using simple procedures. You will be shown how to mock HTTP Requests using HTTPretty, and will learn to interact with social media using Requests. This book will help you to grasp the art of web scraping with the BeautifulSoup and Python Requests libraries, and will then paddle you through Requests impressive ability to interact with APIs. It will empower you with the best practices for seamlessly drawing data from web apps. Last but not least, you will get the chance to polish your skills by implementing a RESTful Web API with Python and Flask! Table of Contents Chapter 1. Interacting with the Web Using Requests Chapter 2. Digging Deep into Requests Chapter 3. Authenticating with Requests Chapter 4. Mocking HTTP Requests Using HTTPretty Chapter 5. Interacting with Social Media Using Requests Chapter 6. Web Scraping with Python Requests and BeautifulSoup Chapter 7. Implementing a Web Application with Python Using Flask
About This Book A fast-paced guide that demonstrates the use of Python Requests with the help of examples Learn web scraping with Beautiful Soup and Python Requests libraries Interact with social networking sites such as Facebook, Twitter, and Reddit to retrieve data from them Who This Book Is For If you are a Python administrator or developer interested in interacting with web APIs and have a passion for creating your own web applications, this is the book for you. Basic knowledge of Python programming, APIs, and web services will be an advantage. What You Will Learn Demonstrate the use of Python Requests with the help of examples Use the Requests module to deal with the inner sections of the request-response cycles Implement the RESTful Web API with Python Requests Authenticate Requests using different authentication methods Emulate server actions and interact with a mock server Interact with social networking sites such as Facebook, Twitter, and reddit Scrape the Web with Python Requests and BeautifulSoup Build your own web application with Flask In Detail Python is one of the most popular programming languages of our era; the Python Requests library is one of the world's best clients, with the highest number of downloads. It allows hassle-free interactions with web applications using simple procedures. You will be shown how to mock HTTP Requests using HTTPretty, and will learn to interact with social media using Requests. This book will help you to grasp the art of web scraping with the BeautifulSoup and Python Requests libraries, and will then paddle you through Requests impressive ability to interact with APIs. It will empower you with the best practices for seamlessly drawing data from web apps. Last but not least, you will get the chance to polish your skills by implementing a RESTful Web API with Python and Flask!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值