forked from Bruuuuuuce/PKUAutoSubmit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
69 lines (55 loc) · 2.14 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
67
68
69
# -*- coding: utf-8
import env_check
from configparser import ConfigParser
from selenium.webdriver.chrome.options import Options
from func import *
import warnings
import sys
import os
import re
warnings.filterwarnings('ignore')
def sys_path(browser):
path = f'./{browser}/bin/'
if sys.platform.startswith('win'):
return path + f'{browser}.exe'
elif sys.platform.startswith('linux'):
return path + f'{browser}-linux'
elif sys.platform.startswith('darwin'):
return path + f'{browser}'
else:
raise Exception('暂不支持该系统')
def go(config):
conf = ConfigParser()
conf.read(config, encoding='utf8')
userName, password = dict(conf['login']).values()
campus, reason, detail = dict(conf['common']).values()
destination, track = dict(conf['out']).values()
habitation, district, street = dict(conf['in']).values()
capture = conf.getboolean('capture', '是否需要备案历史截图')
path = conf['capture']['截图保存路径']
wechat = conf.getboolean('wechat', '是否需要微信通知')
sckey = conf['wechat']['SCKEY']
run(driver_pjs, userName, password, campus, reason, detail, destination, track,
habitation, district, street, capture, path, wechat, sckey)
if __name__ == '__main__':
driver_pjs = webdriver.PhantomJS(executable_path=sys_path(browser="phantomjs"))
# chrome_options = Options()
# chrome_options.add_argument("--headless")
# driver_pjs = webdriver.Chrome(
# options=chrome_options,
# executable_path=sys_path(browser="chromedriver"),
# service_args=['--ignore-ssl-errors=true', '--ssl-protocol=TLSv1'])
print('Driver Launched\n')
lst_conf = sorted([
fileName for fileName in os.listdir()
if re.match(r'^config[0-9][0-9]*\.ini$', fileName)
],
key=lambda x: int(re.findall(r'[0-9]+', x)[0]))
print(f'读取到{len(lst_conf)+1}份配置文件\n')
print('||第1个学生备案||')
go('config.ini')
if lst_conf:
for num, config in enumerate(lst_conf):
print(f'||第{num+2}个学生备案||')
go(config)
driver_pjs.quit()