import urllib.request, urllib.error
url = 'http://www.google.com/asdfsf'
try:
    conn = urllib.request.urlopen(url)
except urllib.error.HTTPError as e:
    print(e.code)
except urllib.error.URLError as e:
    print('URLError')
else:
    print('good')
In Python, how do I use urllib to see if a website is 404 or 200?