from urllib import request, error

'''
URLError是HTTPError的父类
输入一个不存在的页面, 捕获URLError异常
'''

try:
    response = request.urlopen('https://cuiqingcai.com/index.htm')
except error.URLError as e:
    print(e.reason)

a0e1e90560d5664c0767f9f45b712dbcdccef31a
<mask token>

<mask token>
try:
    response = request.urlopen('https://cuiqingcai.com/index.htm')
except error.URLError as e:
    print(e.reason)

from urllib import request, error
<mask token>
try:
    response = request.urlopen('https://cuiqingcai.com/index.htm')
except error.URLError as e:
    print(e.reason)

from urllib import request, error

'''
URLError是HTTPError的父类
输入一个不存在的页面, 捕获URLError异常
'''

try:
    response = request.urlopen('https://cuiqingcai.com/index.htm')
except error.URLError as e:
    print(e.reason)
