diff --git a/DrissionPage/_base/chromium_driver.py b/DrissionPage/_base/chromium_driver.py index 44f3e8b..422eeb4 100644 --- a/DrissionPage/_base/chromium_driver.py +++ b/DrissionPage/_base/chromium_driver.py @@ -9,8 +9,7 @@ from threading import Thread, Event from time import perf_counter from requests import get -from websocket import (WebSocketTimeoutException, WebSocketException, WebSocketConnectionClosedException, - create_connection) +from websocket import WebSocketTimeoutException, WebSocketConnectionClosedException, create_connection class ChromiumDriver(object): @@ -103,7 +102,7 @@ class ChromiumDriver(object): msg = loads(msg_json) except WebSocketTimeoutException: continue - except (WebSocketException, OSError, WebSocketConnectionClosedException): + except: self.stop() return diff --git a/DrissionPage/_commons/web.py b/DrissionPage/_commons/web.py index a94bacf..030c181 100644 --- a/DrissionPage/_commons/web.py +++ b/DrissionPage/_commons/web.py @@ -266,6 +266,8 @@ def set_browser_cookies(page, cookies): '%a, %d %b %y %H:%M:%S GMT').timestamp() if cookie['value'] is None: cookie['value'] = '' + elif not isinstance(cookie['value'], str): + cookie['value'] = str(cookie['value']) if cookie['name'].startswith('__Secure-'): cookie['secure'] = True diff --git a/DrissionPage/_configs/chromium_options.py b/DrissionPage/_configs/chromium_options.py index b8e2eec..fca7805 100644 --- a/DrissionPage/_configs/chromium_options.py +++ b/DrissionPage/_configs/chromium_options.py @@ -340,6 +340,14 @@ class ChromiumOptions(object): on_off = None if on_off else False return self.set_argument('--mute-audio', on_off) + def incognito(self, on_off=True): + """设置是否使用无痕模式启动 + :param on_off: 开或关 + :return: 当前对象 + """ + on_off = None if on_off else False + return self.set_argument('--incognito', on_off) + def ignore_certificate_errors(self, on_off=True): """设置是否忽略证书错误 :param on_off: 开或关 diff --git a/DrissionPage/_configs/chromium_options.pyi b/DrissionPage/_configs/chromium_options.pyi index ec843ca..8398182 100644 --- a/DrissionPage/_configs/chromium_options.pyi +++ b/DrissionPage/_configs/chromium_options.pyi @@ -113,6 +113,8 @@ class ChromiumOptions(object): def mute(self, on_off: bool = True) -> ChromiumOptions: ... + def incognito(self, on_off: bool = True) -> ChromiumOptions: ... + def set_user_agent(self, user_agent: str) -> ChromiumOptions: ... def set_proxy(self, proxy: str) -> ChromiumOptions: ... diff --git a/DrissionPage/_configs/configs.ini b/DrissionPage/_configs/configs.ini index 7a22f7a..4355442 100644 --- a/DrissionPage/_configs/configs.ini +++ b/DrissionPage/_configs/configs.ini @@ -4,7 +4,7 @@ download_path = [chromium_options] address = 127.0.0.1:9222 browser_path = chrome -arguments = ['--no-first-run', '--disable-infobars', '--disable-popup-blocking'] +arguments = ['--no-default-browser-check', '--disable-suggestions-ui', '--no-first-run', '--disable-infobars', '--disable-popup-blocking'] extensions = [] prefs = {'profile.default_content_settings.popups': 0, 'profile.default_content_setting_values': {'notifications': 2}} flags = {}