["python","http","scripting","httprequest","http-head"]
Checking if a website is up via Python

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 Related How do you send a HEAD HTTP request in 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