python3 网页抓取https页面

python yekong
from urllib import request
import ssl

#ssl免验证
#创建一个不需要验证的上下文
ssl._create_default_https_context=ssl._create_unverified_context
#而不是ssl._create_unverified_context()

# ssl._create_default_https_context = ssl._create_unverified_context
base_url = "https://www.wanjunshijie.com/" #urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]

response = request.urlopen(base_url)
html = response.read()

# html = html.decode("utf-8")
print(html)
喜欢