Skip to content

Instantly share code, notes, and snippets.

@013
Last active August 29, 2015 14:03
Show Gist options
  • Save 013/a35e2177c04a24c6a8d4 to your computer and use it in GitHub Desktop.
Save 013/a35e2177c04a24c6a8d4 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# 2014/07/09 Ryan Linnit
import re
import smtplib
import requests
email = '[email protected]'
postcode = 'WF13 3RL'
session = requests.session()
def main():
login()
checkWinner()
# Log in to add to your bonus, check bonus draw
def login():
r = session.post("http://freepostcodelottery.com/", params={'register-email': email, 'register-ticket': postcode})
try:
bonusPostcode = re.search('bonus-ticket">(.+?)<', r.text, re.M).groups()[0]
sendmail(bonusPostcode, draw="bonus")
except AttributeError:
pass # No bonus found
# See if you're a weiner
def checkWinner():
r = session.post("http://freepostcodelottery.com/speech/4.txt")
winningPostcode = re.search('\'(.+?)\'', r.text).groups()[0]
sendmail(winningPostcode)
def sendmail(winningPostcode, draw="main"):
# Only send an e-mail if we win
if postcode.replace(" ", "") == winningPostcode.replace(" ", ""):
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail('[email protected]',
[email, '[email protected]'],
"Your Postcode '%s' has won the %s draw!\n" % (winningPostcode, draw))
except Exception,e:
print "Unable to send: %s" % str(e)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment