python3 代码怎样关闭url与ssl属性校验
2个回答
展开全部
import urllib.request
import ssl
url = "httpsurl"
header = headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11"
}
request = urllib.request.Request(url, headers=header)
context = ssl._create_unverified_context() # 忽略ssl证书验证
res = urllib.request.urlopen(request, context=context)
print(res.read().decode("utf8"))
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询