Created
May 9, 2015 12:40
-
-
Save iamlixiao/ca3998e4cabf6bb9df47 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import requests | |
| import smtplib | |
| import base64 | |
| from email.mime.text import MIMEText | |
| import time | |
| movieid = '207295462' #Enter movie id aassgined by gewara, usually 9 digits | |
| date = '2015-05-16' #Enter intended date, format should be YYYY-MM-DD | |
| cinemaid = '2' #Enter cinema id assigned by gewara | |
| url = 'http://www.gewara.com/movie/ajax/getOpiItem.xhtml?movieid='+movieid+'&fyrq='+date+'&cid='+cinemaid | |
| r = requests.get(url) | |
| if '/cinema/order' in r.content: | |
| avail = 1 | |
| else: | |
| avail = 0 | |
| if avail == 1: | |
| status = 'available' | |
| if avail == 0: | |
| status = 'not ready' | |
| check_time = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()) | |
| f = open ('log.txt','a') | |
| line = check_time + ' tickets are ' + status + '\n' | |
| f.write(line) | |
| f.close() | |
| g = open('status.txt','r') | |
| current = g.read() | |
| g.close() | |
| h = open('status.txt','w') | |
| h.write(status) | |
| h.close() | |
| if current == 'not ready' and status == 'available': | |
| send = 1 | |
| else: | |
| send = 0 | |
| if send == 1: | |
| FROM = 'example@example.com' #use an email address you can access here | |
| TO = ['example@example.com'] #use the email address to recieve notification | |
| USERNAME = 'example@example.com' #same as FROM, enter an email address you can access here | |
| PASSWORD = 'password' #password of FROM | |
| SMTPSERVER = 'smtp.example.com' #smtpserver of your email service provider | |
| message = MIMEText('Contents') | |
| message['From'] = FROM | |
| message['To'] = ', '.join(TO) | |
| message['Subject'] = 'Subject' | |
| server = smtplib.SMTP(SMTPSERVER) | |
| server.starttls() | |
| server.login(USERNAME, PASSWORD) | |
| server.sendmail(FROM, TO, message.as_string()) | |
| server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment