forked from mirror/MrDoc
新增chromedriver自定义路径配置项
This commit is contained in:
parent
e8b4c70918
commit
d8f7abf0b6
@ -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)
|
||||
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user