-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
66 lines (55 loc) · 1.77 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: UTF-8 -*-
import requests
import time
import json
import sys
def get_format_time(time_stamp):
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time_stamp))
start_time = time.time()
print('此次运行开始时间为 :', get_format_time(start_time))
# email 覆盖于此
# passwd 覆盖于此
# 开始尝试签到
file_path = sys.path[0] + r'/config.json'
with open(file_path, 'r') as f:
config = json.load(f)
root_url = config['root_url']
try_times = config['try_times']
sleep_second = config['sleep_second']
print('成功载入配置文件')
for i in range(try_times):
print('第', i + 1, '次尝试签到')
try:
session = requests.Session()
# 登录
print('正在登录...')
login_url = f'{root_url}/auth/login'
res = session.post(login_url,
data={
'email': email,
'passwd': passwd,
'code': ''
})
print('\n\t', res.json(), '\n')
# 签到
print('正在签到...')
chekin_url = f'{root_url}/user/checkin'
res = session.post(chekin_url)
print('\n\t', res.json(), '\n')
except Exception as e:
print(e)
print('******** 签到失败')
else:
print('******** 签到成功')
finally:
try:
session.close()
except:
pass
print('休眠', sleep_second, '秒\n')
time.sleep(sleep_second)
stop_time = time.time()
print('此次运行开始时间为 :', get_format_time(start_time))
print('此次运行结束时间为 :', get_format_time(stop_time))
print('此次运行总共耗时 :',
time.strftime("%H:%M:%S", time.gmtime(stop_time - start_time)))