-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
82 lines (73 loc) · 3.05 KB
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
import argparse
import requests
import smtplib
def main(args):
# Define Headers
headers = {'Host' : 'www.inoxmovies.com',
'User-Agent' : 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) \
Gecko/20100101 Firefox/50.0',
'Accept' : '*/*',
'Accept-Language' : 'en-US,en;q=0.5',
'Accept-Encoding' : 'gzip, deflate, br',
'X-Requested-With' : 'XMLHttpRequest',
'Referer' : 'https://www.inoxmovies.com/Index.aspx',
'Cookie' : 'InoxCityCookie=CityID=Wpu3J5wC3A33ejfMG9heYw==&CityNam \
e=Hyderabad; _ga=GA1.2.12057937.1483898455; _gat=1',
'Connection' : 'keep-alive',
'Cache-Control' : 'max-age=0',
'Content-Length' : '0',
'user-agent' : 'my-app/0.0.1'}
# Request URL
r = requests.get(args.url,headers=headers)
if args.movie_name in r.text:
# Fill values
gmail_user = args.email
gmail_pwd = args.password
FROM = '[email protected]'
TO = args.email
SUBJECT = "Please book tickets for " + args.movie_name + " in \
inoxmovies.com"
TEXT = "Subject says it all"
# Prepare actual message
message = """From: %s\nTo: %s\nSubject: %s\n\n%s \
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# Send Email
try:
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls()
server.login(gmail_user, gmail_pwd)
server.sendmail(FROM, TO, message)
server.close()
print 'Successfully sent the mail'
except:
print "Failed to send mail"
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Reminder to \
book tickets in inox movies online.')
parser.add_argument('-m', '--movie-name',
type=str,
required=False,
default='Khaidi',
help='Movie Name')
parser.add_argument('-e', '--email',
type=str,
required=False,
default='[email protected]',
help='Gmail Id',)
parser.add_argument('-p', '--password',
type=str,
required=True,
help='Gmail password')
parser.add_argument('-u', '--url',
type=str,
required=False,
default='https://www.inoxmovies.com/Handlers/TestQuickBookingHandler.ashx?GetMovieList=True&CinemaID=0',
help='Inox Movies Movies List URL')
while(1):
main(parser.parse_args())