By using python, how can I check if a website is up? From what I read, I need to check the "HTTP HEAD" and see status code "200 OK", but how to do so ?
Cheers
You could try to do this with getcode()
from urllib
>>> print urllib.urlopen("http://www.stackoverflow.com").getcode()
>>> 200
EDIT: For more modern python, i.e. python3
, use:
import urllib.request
print(urllib.request.urlopen("http://www.stackoverflow.com").getcode())
>>> 200