Open Laboratory for Technocrats

Grab the developer role, learn concepts & prepare with senior software engineers to get solutions for problems in a software job. Coding and Programming Solutions crafted for you.

Check website is up and running - Python

Lets see how we can check if the website is up and working or its down in python.

Python provides minimal code to check this kind of requests and its fast.

Here is the code:
import urllib
import sys
try:
    httpcode =  urllib.urlopen("http://www.google.com").getcode()
    if httpcode == 200:
        print "Site is up and running"
    else:
        print "Site is not up"
except:
print "Oops!  Exception occured for this site: ", sys.exc_info()[0]
Explanation will be updated soon

Top #3 Articles