Python无法验证ssl证书怎么解决
发布时间:2025-05-08 10:40:47

无法验证Pythonssl证书的解决方案如下:
相关建议:Python教程
importrequests
frombs4importBeautifulSoup
importtime
importre
url='https://music.163.com/#/search/m/?s=%E7%BA%A2%E6%98%AD%E6%84%BF&type=100'
#header必须以字典的形式出现
header={'User-Agent':'Mozilla5.0(WindowsNT10.0.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome
/72.0.3626.121Safari/537.36'}
#s=requests.session()
#SSL验证失败发生在请求中,解决方案是让requests忽略SSL证书的验证
#没有verify=False,SSLErrorororo
web_url=requests.get(url,headers=header,verify=False)
soup=BeautifulSoup(web_url.content,'lxml')
print(web_url.text)
下一篇 python是什么语言写的
