Python无法验证ssl证书怎么解决
Python无法验证ssl证书?解决方法如下:
相关推荐:《Python教程》
import requestsfrom bs4 import BeautifulSoup
import time
import re
url = 'https://music.163.com/#/search/m/?s=%E7%BA%A2%E6%98%AD%E6%84%BF&type=100'
#header必须是以字典的形式出现
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome
/72.0.3626.121 Safari/537.36'}
#s = requests.session()
#请求时发生SSL验证失败,解决方法是让requests忽略对SSL证书的验证
#在没有verify=False时会出现SSLError
web_url = requests.get(url,headers=header,verify=False)
soup = BeautifulSoup(web_url.content,'lxml')
print(web_url.text)
以上是 Python无法验证ssl证书怎么解决 的全部内容, 来源链接: utcz.com/z/522336.html