From 649f699618d26b77ad247748cd49103d283c97d6 Mon Sep 17 00:00:00 2001 From: g1879 Date: Sat, 21 Nov 2020 19:40:46 +0800 Subject: [PATCH] =?UTF-8?q?get=5Fmatch=5Fdriver()=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8E=A5=E6=94=B6chrome=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/easy_set.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DrissionPage/easy_set.py b/DrissionPage/easy_set.py index 8fe69b4..6d9a39c 100644 --- a/DrissionPage/easy_set.py +++ b/DrissionPage/easy_set.py @@ -191,15 +191,19 @@ def check_driver_version(driver_path: str = None, chrome_path: str = None) -> bo # -------------------------自动识别chrome版本号并下载对应driver------------------------ -def get_match_driver(ini_path: str = None, save_path: str = None) -> None: +def get_match_driver(ini_path: str = None, + save_path: str = None, + chrome_path: str = None) -> None: """自动识别chrome版本并下载匹配的driver \n :param ini_path: 要读取和修改的ini文件路径 :param save_path: chromedriver保存路径 + :param chrome_path: 指定chrome.exe位置 :return: None """ save_path = save_path or str(Path(__file__).parent) - chrome_path = _get_chrome_path(ini_path) + chrome_path = chrome_path or _get_chrome_path(ini_path) + chrome_path = Path(chrome_path).absolute() if chrome_path else None print('chrome.exe路径', chrome_path, '\n') ver = _get_chrome_version(chrome_path) @@ -219,7 +223,7 @@ def get_match_driver(ini_path: str = None, save_path: str = None) -> None: if driver_path: Path(zip_path).unlink() - set_paths(driver_path=driver_path, ini_path=ini_path, check_version=False) + set_paths(driver_path=driver_path, chrome_path=str(chrome_path), ini_path=ini_path, check_version=False) if not check_driver_version(driver_path, chrome_path): print('获取失败,请手动配置。')