This repository has been archived by the owner on Jan 19, 2023. It is now read-only.
forked from Bruuuuuuce/PKUAutoSubmit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
61 lines (48 loc) · 1.61 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
# -*- coding: utf-8
import env_check
from configparser import ConfigParser
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
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')
credentials = dict(conf['login'])
config_dict = dict(conf['common'])
run(driver_pjs, credentials, config_dict)
if __name__ == '__main__':
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()