Skip to content

Instantly share code, notes, and snippets.

@seunggabi
Created September 28, 2019 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seunggabi/3c3678ff16bb1de9bb447be6479cfdd6 to your computer and use it in GitHub Desktop.
Save seunggabi/3c3678ff16bb1de9bb447be6479cfdd6 to your computer and use it in GitHub Desktop.
checkHttpStatus.py
from urllib.request import urlopen
from urllib.error import HTTPError
def checkHttpStatus(URL):
try:
res = urlopen(URL)
return res.status
except HTTPError as e:
code = e.getcode()
return code
print(checkHttpStatus("http://google.com"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment