mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
有传入两种配置时不读取ini文件
This commit is contained in:
parent
c962e21163
commit
deab1816bb
@ -24,7 +24,6 @@ class Drission(object):
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
driver_options: Union[dict, Options] = None,
|
driver_options: Union[dict, Options] = None,
|
||||||
session_options: dict = None,
|
session_options: dict = None,
|
||||||
# driver_path: str = None,
|
|
||||||
ini_path: str = None,
|
ini_path: str = None,
|
||||||
proxy: dict = None):
|
proxy: dict = None):
|
||||||
"""初始化配置信息,但不生成session和driver实例
|
"""初始化配置信息,但不生成session和driver实例
|
||||||
@ -35,17 +34,21 @@ class Drission(object):
|
|||||||
"""
|
"""
|
||||||
self._session = None
|
self._session = None
|
||||||
self._driver = None
|
self._driver = None
|
||||||
om = OptionsManager(ini_path)
|
self._driver_path = 'chromedriver'
|
||||||
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._proxy = proxy
|
self._proxy = proxy
|
||||||
|
if session_options is None:
|
||||||
if 'driver_path' in self._driver_options and self._driver_options['driver_path']:
|
self._session_options = OptionsManager(ini_path).get_option('session_options')
|
||||||
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']
|
|
||||||
else:
|
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
|
@property
|
||||||
def session(self) -> HTMLSession:
|
def session(self) -> HTMLSession:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user