-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (35 loc) · 1.19 KB
/
main.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
from requests import session
import smtplib
import threading
#Identifiants à remplir
pamplemousse_user = "XXXXXX"
pamplemousse_pass = "XXXXXX"
gmail_user = 'XXXXXX@gmail.com'
gmail_password = 'XXXXXXX'
payload = {
"sph_org_location": '/',
"sph_username": pamplemousse_user,
"sph_password": pamplemousse_pass,
}
#Authentification et requête de la page de notes
with session() as c:
c.post('https://pamplemousse.ensae.fr/site_publishing_helper/login_check/0', data=payload)
response = c.get('https://pamplemousse.ensae.fr/index.php?p=105')
sent_from = gmail_user
to = [gmail_user]
email_text = 'Changement dans les notes'
old = response.text
def check():
threading.Timer(300.0, check).start() #intervalle de temps pour la vérification
global old
with session() as c:
c.post('https://pamplemousse.ensae.fr/site_publishing_helper/login_check/0', data=payload)
response = c.get('https://pamplemousse.ensae.fr/index.php?p=105')
if response.text != old:
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.ehlo()
server.login(gmail_user, gmail_password)
server.sendmail(sent_from, to, email_text)
server.close()
old = response.text
check()