本文主要是介绍报错:ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the ‘ssl‘ module is compiled wi,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
报错:
ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the ‘ssl’ module is compiled with OpenSSL 1.1.0h 27 Mar 2018.
解决办法:
Terminal窗口执行:pip install urllib3==1.26.15
Urllib3是一个功能强大,用于HTTP客户端的Python库,它包含4个模块:
urllib.request---请求模块,用于发起网络请求urllib.parse---解析模块,用于解析urlurllib.error---异常处理模块,用于处理request引起的异常urllib.robotparser robots.tx---用于解析robots.txt文件
安装命令:
安装命令:pip install urllib3
urllib3发送网络请求前,首先创建PoolManager对象 ,然后通过对象调用request()方法来发送网络请求
method:请求方式
url:请求地址
headers:请求头信息
fields:请求体数据
body:指定请求体类型
tiemout:设置超时时间
get请求
import urllib3 #导入urllib3模块
urllib3.disable_warnings()
http = urllib3.PoolManager()
re = http.request('get',请求地址)
print(resp.data) -- 查看响应数据
post请求
import urllib3 #导入urllib3模块
urllib3.disable_warnings()
http = urllib3.PoolManager()
re = http.request('post',请求地址,fields=请求参数, headers=请求头)
print(resp.data) -- 查看响应数据
这篇关于报错:ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the ‘ssl‘ module is compiled wi的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!