#Google IO Poll Script 
#by: Wes Maag 
#on: 1/21/2011
#
#desc: Just a short script to poll the google-io page for any changes
#the variables from and to should be entered for this to work, you will also
#need to specify what smtp server you want to use if you do not have one set up
#
#I didnt think to add any error handling since i just wanted to get something up quickly
#so you may want to add that if you care to.
#
#Another addition would be to add some sort of keyboard inturrupt that breaks out of the loop
#again I was just lazy and didn't add it because i could always CTRL-C out of it

import urllib, md5, time, smtplib
from email.mime.text import MIMEText

to = "youremail@here.com"
from_em = "something@blah.com"

def gethash():
	f = urllib.urlopen("https://google-io.com")
	m = md5.new()
	while True:
		d = f.read()
		if not d:
			break
		m.update(d)
	f.close()
	return m.hexdigest()
def sendEmail():
	msg = MIMEText("Google I/O Page just updated.",'html')
	msg['Subject'] = "Google I/O updated"
	msg['From'] = from_em
	msg['To'] = to
	s = smtplib.SMTP('localhost')
	s.sendmail(from_em, [to], msg.as_string())
	s.quit()

hash = ""
while True:
	test = gethash()
	if test != hash:
		sendEmail()
		hash = test
	time.sleep(60)





