diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index a241082..4a88739 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -14,4 +14,4 @@ from ._pages.chromium_page import ChromiumPage from ._pages.mix_page import MixPage from ._pages.mix_page import MixPage as WebPage -__version__ = '4.1.0.0b9' +__version__ = '4.1.0.0b10' diff --git a/DrissionPage/_base/driver.py b/DrissionPage/_base/driver.py index 22b2b31..bf2916b 100644 --- a/DrissionPage/_base/driver.py +++ b/DrissionPage/_base/driver.py @@ -15,7 +15,7 @@ from websocket import (WebSocketTimeoutException, WebSocketConnectionClosedExcep WebSocketException, WebSocketBadStatusException) from .._functions.settings import Settings -from ..errors import PageDisconnectedError +from ..errors import PageDisconnectedError, BrowserConnectError class Driver(object): @@ -206,6 +206,8 @@ class Driver(object): raise RuntimeError('请升级websocket-client库。') else: return + except ConnectionRefusedError: + raise BrowserConnectError('浏览器未开启或已关闭。') self._recv_th.start() self._handle_event_th.start() return True diff --git a/DrissionPage/_configs/chromium_options.py b/DrissionPage/_configs/chromium_options.py index 0d7bed9..bec890e 100644 --- a/DrissionPage/_configs/chromium_options.py +++ b/DrissionPage/_configs/chromium_options.py @@ -214,14 +214,14 @@ class ChromiumOptions(object): :param value: 设置项名,有值的设置项传入设置名称即可 :return: 当前对象 """ - del_list = [] + elements_to_delete = [arg for arg in self._arguments if arg == value or arg.startswith(f'{value}=')] + if not elements_to_delete: + return self - for argument in self._arguments: - if argument == value or argument.startswith(f'{value}='): - del_list.append(argument) - - for del_arg in del_list: - self._arguments.remove(del_arg) + if len(elements_to_delete) == 1: + self._arguments.remove(elements_to_delete[0]) + else: + self._arguments = [arg for arg in self._arguments if arg not in elements_to_delete] return self