-
Notifications
You must be signed in to change notification settings - Fork 0
/
clock-out.py
75 lines (63 loc) · 2.28 KB
/
clock-out.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
import requests
from fake_useragent import UserAgent
import json
import datetime
import holidays
ua = UserAgent()
session = requests.session()
ph_holidays = holidays.PH()
if datetime.datetime.today() in ph_holidays:
# Today is a holiday Labor Day 2023-05-09 12:59
print('Today is a holiday', ph_holidays.get(datetime.datetime.today().isoformat()), datetime.datetime.today().strftime('%Y-%m-%d %I:%M'))
else:
headers1 = {
'User-Agent': ua.google,
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US,en;q=0.5',
'Content-Type': 'application/json',
'Authorization': 'Bearer null',
'Origin': 'https://app.aanyahr.com',
'Connection': 'keep-alive',
'Referer': 'https://app.aanyahr.com/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
}
json_data1 = {
'username': '<username>',
'password': '<password>',
'company_code': '<company>',
'remember': None,
# ip addresses optional
'ipv1': '<ip>',
'ipv2': '<ip>',
}
response1 = session.post('https://v15.aanyahr.com:9000/api/AccountManagement/AuthenticateLogin', headers=headers1, json=json_data1)
json_response1 = json.loads(response1.text)
# json_response1['token']
headers2 = {
'User-Agent': ua.google,
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'en-US,en;q=0.5',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + json_response1['token'],
'Origin': 'https://app.aanyahr.com',
'Connection': 'keep-alive',
'Referer': 'https://app.aanyahr.com/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
}
json_data2 = {
'in_out': 1,
'log_type_id': '1',
'created_by': '<created_by>',
'series_code': '<series_code>',
}
response2 = session.post(
'https://v15.aanyahr.com:9000/api/AttendanceManagement/attendance_log_in',
headers=headers2,
json=json_data2,
)
# {"in_out":1,"log_type_id":1,"is_schedule":true,"created_by":30207}
print('Clocked Out on', datetime.datetime.now().strftime('%a, %b %d, %Y at %H:%M:%S'))