python3 关于链接错误问题 urllib.error


import urllib.request

import urllib.error

url = 'https://www.taobao.com/4552'

try :
    html = urllib.request.urlopen(url)

    html = html.read().decode('utf-8')

    print(html)

except urllib.error.URLError as e:
    print('输入的网址错误:404页面找不到了')
#url = 'https://www.w3cschool.cn/pyth/'
except ValueError as e:
    print('网址类型不对')
#url = 'https://www.taobao.com/4552'
except urllib.error.HTTPError as e:

    print('HTTP Error 403 禁止爬虫')


你可能感兴趣的:(爬虫)