Last active
September 25, 2015 09:47
-
-
Save rgarcia/901854 to your computer and use it in GitHub Desktop.
script to tell us when the lollapalooza front page changes, so that we can get in on ticket deals quickly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# script to tell us when the lollapalooza front page has changed, presumably to get ticket deals | |
import urllib2 | |
import time | |
import md5 | |
import smtplib | |
import random | |
from email.mime.text import MIMEText | |
people = [ ] # put people to notify here | |
urltowatch = 'http://www.lollapalooza.com/' | |
smtpserverURL = 'smtp.gmail.com:587' | |
smtpserverLogin = 'yourlogin@gmail.com' | |
smtpserverPass = 'yourpassword' | |
pagehash = None | |
while True: | |
page = urllib2.urlopen(urltowatch) | |
print page.geturl() | |
print page.info() | |
oldpagehash = pagehash | |
pagehash = md5.new(page.read()).digest() | |
if oldpagehash != None and oldpagehash != pagehash: | |
msg = MIMEText(urltowatch) | |
msg['Subject'] = urltowatch + ' has changed!!' | |
msg['From'] = smtpserverLogin | |
msg['To'] = '' | |
# send the message | |
print 'connecting to smtp server...' | |
server = smtplib.SMTP(smtpserverURL) | |
print 'connected' | |
server.starttls() | |
server.login(smtpserverLogin, smtpserverPass) | |
server.sendmail(smtpserverLogin, people, msg.as_string()) | |
server.quit() | |
time.sleep(60 + random.randrange(4, 16)) # every minute + human noise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment