import requests as r
import time
import winsound
USER = YOUR_USERNAME_HERE
PASS = YOUR_PASSWORD_HERE
s = r.Session()
last_th = -1
while True:
res = s.post('https://grades.cs.technion.ac.il',
{'ID': USER, 'Password':PASS, 'submit': 'proceed', 'Page': 'grades.html', 'Login': 1})
if '=xxx' in res.headers.get('Set-Cookie', ''):
raise Exception('Failed to login')
res = s.post('https://grades.cs.technion.ac.il',
{'COOKIE': res.cookies['LastGradesCookie'], 'RecreatePath': 1, 'SEM': '201902'})
res_str = res.text.lower()
if 'finala' not in res_str:
raise Exception('Not in grades page')
if last_th == -1:
last_th = res_str.count("<th>")
continue
elif res_str.count('<th>') != last_th or 'proj' in res_str:
print('Hurray, you have new grades!!!')
duration = 300 # milliseconds
freq = 2000 # Hz
for i in range(100):
winsound.Beep(freq, duration)
time.sleep(duration/3000)
break
else:
print('No grades yet. Sorry :-(')
time.sleep(600)
Comments