Created
September 28, 2019 08:19
-
-
Save seunggabi/3c3678ff16bb1de9bb447be6479cfdd6 to your computer and use it in GitHub Desktop.
checkHttpStatus.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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