This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scriptabsen.py
68 lines (51 loc) · 1.59 KB
/
scriptabsen.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
import pytz
import time
from datetime import datetime
def runscript(email, password, browser):
try:
browser.get("https://siswa.smktelkom-mlg.sch.id")
except:
browser.close()
return False
emailinput, passinput, enter = browser.find_element_by_name('email'), browser.find_element_by_name('password'), browser.find_element_by_id('masuk')
emailinput.send_keys(str(email))
passinput.send_keys(str(password))
enter.click()
time.sleep(1)
try:
browser.get("https://siswa.smktelkom-mlg.sch.id/presnow")
except:
browser.close()
return False
while True:
time_now = datetime.now(pytz.timezone('Asia/Jakarta'))
if time_now.strftime('%H') == '06':
return absen(browser)
def absen(browser):
try:
browser.refresh()
inputabsen, simpan = browser.find_element_by_xpath('//label[@for="M"]'), browser.find_element_by_id("simpan")
inputabsen.click()
simpan.click()
except:
pass
return cek_absen(browser)
def cek_absen(browser):
try:
tmp = browser.find_element_by_class_name('number')
if tmp.text == 'Masuk':
logout(browser)
return True
else:
logout(browser)
return False
except:
browser.refresh()
return cek_absen(browser)
def logout(browser):
browser.get("https://siswa.smktelkom-mlg.sch.id/login/logout")
browser.close()
def override(email, password, browser):
while True:
if runscript(email, password, browser) == True:
return True