From 221204b2f29d7edea4ba514b0479a143b5b818c8 Mon Sep 17 00:00:00 2001 From: g1879 Date: Wed, 27 Dec 2023 17:29:42 +0800 Subject: [PATCH] =?UTF-8?q?4.0.0b31=E5=AE=8C=E5=96=84Driver=E7=9A=84stop()?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=9B=E4=BC=98=E5=8C=96=E5=BD=95=E5=83=8F?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E9=80=BB=E8=BE=91=EF=BC=9B=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E5=A2=9E=E5=8A=A0save()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_pages/chromium_base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DrissionPage/_pages/chromium_base.py b/DrissionPage/_pages/chromium_base.py index 1a41abc..30830ac 100644 --- a/DrissionPage/_pages/chromium_base.py +++ b/DrissionPage/_pages/chromium_base.py @@ -17,7 +17,7 @@ from .._elements.none_element import NoneElement from .._elements.session_element import make_session_ele from .._functions.locator import get_loc, is_loc from .._functions.settings import Settings -from .._functions.tools import raise_error +from .._functions.tools import raise_error, make_valid_name from .._functions.web import location_in_viewport from .._units.actions import Actions from .._units.listener import Listener @@ -1165,7 +1165,8 @@ def get_mhtml(page, path=None, name=None): """ r = page.run_cdp('Page.captureSnapshot')['data'] path = path or '.' - name = name or page.title + Path(path).mkdir(parents=True, exist_ok=True) + name = make_valid_name(name or page.title) with open(f'{path}{sep}{name}.mhtml', 'w', encoding='utf-8') as f: f.write(r) return r