From 747805ad7fd08fe98bdb532b74e4ae216b5fb30d Mon Sep 17 00:00:00 2001 From: g1879 Date: Tue, 24 Jan 2023 15:34:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=87=AA=E5=8A=A8=E5=88=86?= =?UTF-8?q?=E9=85=8D=E7=AB=AF=E5=8F=A3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/configs/chromium_options.py | 6 ++++-- DrissionPage/configs/configs.ini | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DrissionPage/configs/chromium_options.py b/DrissionPage/configs/chromium_options.py index 0c06d93..4d42d3b 100644 --- a/DrissionPage/configs/chromium_options.py +++ b/DrissionPage/configs/chromium_options.py @@ -54,7 +54,7 @@ class ChromiumOptions(object): if self._auto_port: port, path = PortFinder().get_port() self._debugger_address = f'127.0.0.1:{port}' - self.set_paths(user_data_path=path) + self.set_argument('--user-data-dir', path) return self.ini_path = None @@ -299,9 +299,11 @@ class ChromiumOptions(object): """ if browser_path is not None: self._binary_location = str(browser_path) + self._auto_port = False if local_port is not None: self._debugger_address = f'127.0.0.1:{local_port}' + self._auto_port = False if debugger_address is not None: self._debugger_address = debugger_address @@ -313,6 +315,7 @@ class ChromiumOptions(object): u = str(user_data_path) self.set_argument('--user-data-dir', u) self._user_data_path = u + self._auto_port = False if cache_path is not None: self.set_argument('--disk-cache-dir', str(cache_path)) @@ -330,7 +333,6 @@ class ChromiumOptions(object): self._auto_port = True else: self._auto_port = False - self._debugger_address = '127.0.0.1:9222' return self def save(self, path=None): diff --git a/DrissionPage/configs/configs.ini b/DrissionPage/configs/configs.ini index dd02ce2..bc9afba 100644 --- a/DrissionPage/configs/configs.ini +++ b/DrissionPage/configs/configs.ini @@ -10,7 +10,7 @@ extensions = [] experimental_options = {'prefs': {'profile.default_content_settings.popups': 0, 'profile.default_content_setting_values': {'notifications': 2}, 'plugins.plugins_list': [{'enabled': False, 'name': 'Chrome PDF Viewer'}]}, 'useAutomationExtension': False, 'excludeSwitches': ['enable-automation']} page_load_strategy = normal user = Default -auto_port = True +auto_port = False [session_options] headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'connection': 'keep-alive', 'accept-charset': 'GB2312,utf-8;q=0.7,*;q=0.7'}