新增chromedriver自定义路径配置项

This commit is contained in:
yangjian 2021-02-28 20:40:11 +08:00
parent e8b4c70918
commit d8f7abf0b6
2 changed files with 20 additions and 12 deletions

View File

@ -62,17 +62,22 @@ def __get_pdf_from_html(path: str, timeout: int, install_driver: bool, print_opt
webdriver_prefs['profile.default_content_settings'] = {'images': 2}
if install_driver:
driver = webdriver.Chrome(
ChromeDriverManager(
url='https://npm.taobao.org/mirrors/chromedriver/',
latest_release_url='https://npm.taobao.org/mirrors/chromedriver/LATEST_RELEASE',
chrome_type=ChromeType.GOOGLE if settings.CHROMIUM_DRIVER == 'Chrome' else ChromeType.CHROMIUM
).install(),
options=webdriver_options
)
# 使用指定的chromedriver
if settings.CHROMIUM_DRIVER_PATH is not None:
driver = webdriver.Chrome(executable_path=settings.CHROMIUM_DRIVER_PATH,options=webdriver_options)
# 使用默认的chromedriver
else:
driver = webdriver.Chrome(options=webdriver_options)
if install_driver:
driver = webdriver.Chrome(
ChromeDriverManager(
url='https://npm.taobao.org/mirrors/chromedriver/',
latest_release_url='https://npm.taobao.org/mirrors/chromedriver/LATEST_RELEASE',
chrome_type=ChromeType.GOOGLE if settings.CHROMIUM_DRIVER == 'Chrome' else ChromeType.CHROMIUM
).install(),
options=webdriver_options
)
else:
driver = webdriver.Chrome(options=webdriver_options)
driver.get(path)

View File

@ -1,6 +1,6 @@
[site]
# True表示开启站点调试模式False表示关闭站点调试模式
debug = True
debug = False
[database]
# engine指定数据库类型接受sqlite、mysql、oracle、postgresql
@ -16,4 +16,7 @@ engine = sqlite
# port表示数据库端口
# port = db_port
[selenium]
# driver = Chrome
# 在Windows环境下测试或使用请配置driver = Chrome
# driver = Chrome
# 如果系统无法正确安装或识别chromedriver请指定chromedriver在计算机上的绝对路径
# driver_path = driver_path