Checking if a website is up via Python

You could try to do this with getcode() from urllib

import urllib.request

print(urllib.request.urlopen("https://www.stackoverflow.com").getcode())
200

For Python 2, use

print urllib.urlopen("http://www.stackoverflow.com").getcode()
200

Leave a Comment