From deab1816bb96421349486b83179bb9bb52981b01 Mon Sep 17 00:00:00 2001 From: g1879 Date: Mon, 10 Aug 2020 18:48:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=89=E4=BC=A0=E5=85=A5=E4=B8=A4=E7=A7=8D?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=97=B6=E4=B8=8D=E8=AF=BB=E5=8F=96ini?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/drission.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/DrissionPage/drission.py b/DrissionPage/drission.py index b9a3f0e..779d017 100644 --- a/DrissionPage/drission.py +++ b/DrissionPage/drission.py @@ -24,7 +24,6 @@ class Drission(object): def __init__(self, driver_options: Union[dict, Options] = None, session_options: dict = None, - # driver_path: str = None, ini_path: str = None, proxy: dict = None): """初始化配置信息,但不生成session和driver实例 @@ -35,17 +34,21 @@ class Drission(object): """ self._session = None self._driver = None - om = OptionsManager(ini_path) - self._session_options = session_options or om.get_option('session_options') - self._driver_options = _chrome_options_to_dict(driver_options) or om.get_option('chrome_options') + self._driver_path = 'chromedriver' self._proxy = proxy - - if 'driver_path' in self._driver_options and self._driver_options['driver_path']: - self._driver_path = self._driver_options['driver_path'] - elif 'chromedriver_path' in om.get_option('paths') and om.get_option('paths')['chromedriver_path']: - self._driver_path = om.get_option('paths')['chromedriver_path'] + if session_options is None: + self._session_options = OptionsManager(ini_path).get_option('session_options') else: - self._driver_path = 'chromedriver' + self._session_options = session_options + if driver_options is None: + om = OptionsManager(ini_path) + self._driver_options = om.get_option('chrome_options') + if 'chromedriver_path' in om.get_option('paths') and om.get_option('paths')['chromedriver_path']: + self._driver_path = om.get_option('paths')['chromedriver_path'] + else: + self._driver_options = _chrome_options_to_dict(driver_options) + if 'driver_path' in self._driver_options and self._driver_options['driver_path']: + self._driver_path = self._driver_options['driver_path'] @property def session(self) -> HTMLSession: