Skip to content

Commit

Permalink
Merge pull request Bruuuuuuce#28 from mickelliu/main
Browse files Browse the repository at this point in the history
Change to chromedriver(windows), headless enabled.
  • Loading branch information
Bruuuuuuce authored Oct 19, 2021
2 parents d7ba9a6 + 87c1a64 commit 30f20e3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Binary file added chromedriver/bin/chromedriver.exe
Binary file not shown.
8 changes: 4 additions & 4 deletions func.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ def wechat_notification(userName, sckey):
str(userName) + '成功报备',
safe='/:?=&')) as response:
response = json.loads(response.read().decode('utf-8'))
if response['errmsg'] == 'success':
print('微信通知成功!')
else:
print(str(response['errno']) + ' error: ' + response['errmsg'])
# if response['errmsg'] == 'success':
# print('微信通知成功!')
# else:
# print(str(response['errno']) + ' error: ' + response['errmsg'])


def run(driver, userName, password, campus, reason, destination, track,
Expand Down
26 changes: 17 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8
import env_check
from configparser import ConfigParser
from selenium.webdriver.chrome.options import Options
from func import *
import warnings
import sys
Expand All @@ -9,14 +10,14 @@
warnings.filterwarnings('ignore')


def sys_path():
path = './phantomjs/bin/'
def sys_path(browser):
path = f'./{browser}/bin/'
if sys.platform.startswith('win'):
return path + 'phantomjs.exe'
return path + f'{browser}.exe'
elif sys.platform.startswith('linux'):
return path + 'phantomjs-linux'
return path + f'{browser}-linux'
elif sys.platform.startswith('darwin'):
return path + 'phantomjs'
return path + f'{browser}'
else:
raise Exception('暂不支持该系统')

Expand All @@ -39,10 +40,17 @@ def go(config):


if __name__ == '__main__':
print('Driver Launching...')
driver_pjs = webdriver.PhantomJS(
executable_path=sys_path(),
service_args=['--ignore-ssl-errors=true', '--ssl-protocol=TLSv1'])

# driver_pjs = webdriver.PhantomJS(
# executable_path=sys_path(browser="phantomjs"),
# service_args=['--ignore-ssl-errors=true', '--ssl-protocol=TLSv1'])

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([
Expand Down

0 comments on commit 30f20e3

Please sign in to comment.