/
check.py
194 lines (153 loc) · 7.26 KB
/
check.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
import re
import requests
from bs4 import BeautifulSoup
import sms as w
from mail import sendmail
import time
import pymssql
sem8rem = True
sem7reg = True
sem7rem = True
sem7regd = True
sem7remd = True
conn = pymssql.connect(host='localhost', user='sa', password='contact', database='Gtu_Student')
cursor = conn.cursor()
print("Started")
a = True
while a:
try:
html = requests.get("http://www.gtu.ac.in/result.aspx")
soup = BeautifulSoup(html.content,'html5lib')
msg = ''
columns = soup.findAll(text=re.compile('BE SEM'))
print(columns)
if len(columns) > 0:
for index in range(len(columns)):
txt = columns[index]
msg = msg + txt + ' Declared'
#print 'hieee'
msg = ' '.join(msg.split())
if "BE SEM 8 - Regular (DEC 2017)" in msg and sem8rem:
send = "Result of BE SEM 8 - Regular (DEC 2017) Exam Declared. Check Here--> http://bit.ly/GtuResult All The Best From : KePy"
header = "Result Declared"
try:
sql=("select emailid from studentdetails where semester = 8")
cursor.execute(sql)
data=cursor.fetchall()
for row in data:
print(row[0])
sendmail (send,row[0],header)
except Exception as e:
print("Exception In send MAIL" +str(e))
try:
sql=("select mobile from studentdetails where semester = 8")
cursor.execute(sql)
data=cursor.fetchall()
q=w.sms()
for row in data:
q.send(row[0],send)
n=q.msgSentToday()
print("Sms Sent" +row[0])
except Exception:
print("Exception In SMS")
sem8rem = False
if "BE SEM 7 - Remedial (NOV 2017)" in msg and sem7rem:
send = "Result of BE SEM 7 - Remedial (NOV 2017) Exam Declared. Check Here--> http://bit.ly/GtuResult All The Best From : KePy"
header = "Result Declared"
try:
sql=("select emailid from studentdetails where semester = 7")
cursor.execute(sql)
data=cursor.fetchall()
for row in data:
print(row[0])
sendmail (send,row[0],header)
except Exception as e:
print("Exception In send MAIL" +str(e))
try:
sql=("select mobile from studentdetails where semester = 7")
cursor.execute(sql)
data=cursor.fetchall()
q=w.sms()
for row in data:
q.send(row[0],send)
n=q.msgSentToday()
print("Sms Sent" +row[0])
except Exception:
print("Exception In SMS")
sem7rem = False
if "BE SEM 7 - Regular (NOV 2017)" in msg and sem7reg:
send = "Result of BE SEM 7 - Regular (NOV 2017) Exam Declared. Check Here--> http://bit.ly/GtuResult All The Best From : KePy"
header = "Result Declared"
try:
sql=("select emailid from studentdetails where semester = 7")
cursor.execute(sql)
data=cursor.fetchall()
for row in data:
print(row[0])
sendmail (send,row[0],header)
except Exception as e:
print("Exception In send MAIL" +str(e))
try:
sql=("select mobile from studentdetails where semester = 7")
cursor.execute(sql)
data=cursor.fetchall()
q=w.sms()
for row in data:
q.send(row[0],send)
n=q.msgSentToday()
print("Sms Sent" +row[0])
except Exception:
print("Exception In SMS")
sem7reg = False
if "BE SEM 7 - Remedial (DEC 2017)" in msg and sem7remd:
send = "Result of BE SEM 7 - Remedial (DEC 2017) Exam Declared. Check Here--> http://bit.ly/GtuResult All The Best From : KePy"
header = "Result Declared"
try:
sql=("select emailid from studentdetails where semester = 7")
cursor.execute(sql)
data=cursor.fetchall()
for row in data:
print(row[0])
sendmail (send,row[0],header)
except Exception as e:
print("Exception In send MAIL" +str(e))
try:
sql=("select mobile from studentdetails where semester = 7")
cursor.execute(sql)
data=cursor.fetchall()
q=w.sms()
for row in data:
q.send(row[0],send)
n=q.msgSentToday()
print("Sms Sent" +row[0])
except Exception:
print("Exception In SMS")
sem7remd = False
if "BE SEM 7 - Regular (DEC 2017)" in msg and sem7regd:
send = "Result of BE SEM 7 - Regular (DEC 2017) Exam Declared. Check Here--> http://bit.ly/GtuResult All The Best From : KePy"
header = "Result Declared"
try:
sql=("select emailid from studentdetails where semester = 7")
cursor.execute(sql)
data=cursor.fetchall()
for row in data:
print(row[0])
sendmail (send,row[0],header)
except Exception as e:
print("Exception In send MAIL" +str(e))
try:
sql=("select mobile from studentdetails where semester = 7")
cursor.execute(sql)
data=cursor.fetchall()
q=w.sms()
for row in data:
q.send(row[0],send)
n=q.msgSentToday()
print("Sms Sent" +row[0])
except Exception:
print("Exception In SMS")
sem7regd = False
print(time.ctime())
time.sleep(300)
except Exception as e:
print("Exception Found" +str(e))