[Tutor] Website monitoring program.

Adisegna adisegna at gmail.com
Mon Nov 21 03:15:21 CET 2005


How do I get the counting loop to come back around? It makes one pass fine.
How do I get it to come back up and go through again?

Thanks

-------------------------------------------------------
import urllib, smtplib

urls = ("http://website0.net/imalive.asp",
"http://website1.net/imalive.asp",
"http://website2.net/imalive.asp",
"http://website3.net/imalive.asp",
"http://website4.net/imalive.asp" <http://website4.net/imalive.asp%22>,)

count = 0
for i in urls:
web = urls[count]

for site in urllib.urlopen(web):

good = "400 Bad Request"
bad = "Invalid Hostname"
smtpserver = 'mail.authentium.com <http://mail.authentium.com>'
RECIPIENTS = ['my at address.com']
SENDER = 'website-Verification at address.com'
mssg = site

if good in site:
print "OK"
text_file = open("test.log", "a")
text_file.writelines('sometext : ')
text_file.writelines(site)
text_file.writelines("\n")
text_file.close()

elif bad in site:
print "NOT OK"
text_file = open("test.log", "a")
text_file.writelines('metro-ams : ')
text_file.writelines(site)
text_file.writelines("\n")
text_file.close()
session = smtplib.SMTP(smtpserver)
smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)
if smtpresult:
errstr = ""
for recip in smtpresult.keys():
errstr = """Could not delivery mail to: %s

Server said: %s
%s

%s""" % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr)
raise smtplib.SMTPException, errstr


else:
text_file = open("test.log", "a")
text_file.writelines('Another type of error occurred : ')
text_file.writelines(site)
text_file.writelines("\n")
text_file.close()
print web
count +=1
print count
-----------------------------------------------------------------------------------

Thanks


--
Arthur DiSegna
Network Operations Center
Authentium, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051120/55684598/attachment-0001.htm


More information about the Tutor mailing list