-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSR.py
55 lines (54 loc) · 1.97 KB
/
CSR.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
import sched, time
from requests import Session
from bs4 import BeautifulSoup as bs
from testMail import Mail
import random
#to use sched
timer = sched.scheduler(time.time,time.sleep)
#the loging function
def bot(Timer) :
#target link and loading page
loglink = 'https://example.etc/'
targetlink = 'https://example.etc/next'
#start the session
with Session() as s:
#find and get the token
while True: #to get the authenticity token if the login needs it
site = s.get(loglink)
content = bs(site.content, "html.parser")
try :
token = content.find("input", {"name":"authenticity_token"})["value"]
except :
token = ''
if token != '':
break
else :
print('just keep wait to connect...')
#All what's nessaisaire to log
payload = {
'authenticity_token': token,
'email': '[email protected]',
'password': 'tirarara',
'commit': 'Sign in'}
#send a post request to the login page
s.post(loglink,payload)
#getting the target page content
targetpage = s.get(targetlink)
soup = bs(targetpage.content,'html.parser')
content = soup.prettify()
if ('<tr>' or '<td>' or '</td>') in content :
#get notify via gmail if the condition is true and a tag has been added to the website
mail = Mail("[email protected]" , "tirarara") #gmail,password
mail.send("[email protected]", "subject", "Text") #email recept,subject,text
mail.send("[email protected]", "subject", "Text")
mail.send("[email protected]", "subject", "Text")
mail.send("[email protected]", "subject", "Text")
mail.close()
else :
print('Keep waiting...')
c = random.randint(0, 10)
print('next start after',c,'s')
timer.enter(c,1,bot,(Timer,)) #to loop
#to run
timer.enter(0,1,bot,(timer,))
timer.run()