From 0845814dc5fea6bc4b4c301efe146acc7ddf3c30 Mon Sep 17 00:00:00 2001 From: g1879 Date: Tue, 18 Jul 2023 17:25:43 +0800 Subject: [PATCH] =?UTF-8?q?set=5Fargument('--headless')=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=96=B0=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/configs/chromium_options.py | 7 +++++-- DrissionPage/session_page.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DrissionPage/configs/chromium_options.py b/DrissionPage/configs/chromium_options.py index 7a6b0f5..6f32d90 100644 --- a/DrissionPage/configs/chromium_options.py +++ b/DrissionPage/configs/chromium_options.py @@ -146,8 +146,11 @@ class ChromiumOptions(object): """ self.remove_argument(arg) if value is not False: - arg_str = arg if value is None else f'{arg}={value}' - self._arguments.append(arg_str) + if arg == '--headless' and value is None: + self._arguments.append('--headless=new') + else: + arg_str = arg if value is None else f'{arg}={value}' + self._arguments.append(arg_str) return self def remove_argument(self, value): diff --git a/DrissionPage/session_page.py b/DrissionPage/session_page.py index 738d9a4..7e07aa7 100644 --- a/DrissionPage/session_page.py +++ b/DrissionPage/session_page.py @@ -316,7 +316,7 @@ def set_charset(response): content_type = response.headers.get('content-type', '').lower() if not content_type.endswith(';'): content_type += ';' - charset = search(r'charset[=: ]*(.*)?;', content_type) + charset = search(r'charset[=: ]*(.*)?;?', content_type) if charset: response.encoding = charset.group(1)