Possible Duplicate:
Given a big list of urls, what is a way to check which are active/inactive?
I recently had the idea of a very simple utility script that will test a website to see if it is online or not using two parameters: the url begin tested and the verbosity (how much packet loss can be accepted without raising an alert). I'd like to write the code in Python 2.7.3 and make it as simple as possible.
This is my pseudocode.
def urlCheck(url, verbosity):
badcount = 0
iteration = 0
while iteration < 10:
#ping code here
if website is down:
badcount += 1
iteration += 1
if badcount > verbosity:
print "Phooey. It appears your server is down."
if badcount <= verbosity:
print "Whew! Your server appears to be running smoothly."
My question is, what code should I place in the commented line? (#ping code here)
Thanks!