From 8c870c1c3e673617fafb19acd35fae081d3b91c7 Mon Sep 17 00:00:00 2001 From: g1879 Date: Tue, 26 Dec 2023 17:11:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=AA=E5=9B=BE=E4=B8=8D=E5=86=8D=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=87=8D=E5=91=BD=E5=90=8D=EF=BC=9B=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=BD=95=E5=B1=8F=E6=9C=AA=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/_base/browser.py | 2 +- DrissionPage/_pages/chromium_base.py | 5 +++-- DrissionPage/_pages/chromium_page.py | 2 +- DrissionPage/_units/screencast.py | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DrissionPage/_base/browser.py b/DrissionPage/_base/browser.py index 2171bd1..6556480 100644 --- a/DrissionPage/_base/browser.py +++ b/DrissionPage/_base/browser.py @@ -123,7 +123,7 @@ class Browser(object): :param url: 要匹配url的文本 :param tab_type: tab类型,可用列表输入多个 :param single: 是否返回首个结果的id,为False返回所有信息 - :return: tab id或tab dict + :return: tab id或tab列表 """ tabs = self._driver.get(f'http://{self.address}/json').json() # 不要改用cdp diff --git a/DrissionPage/_pages/chromium_base.py b/DrissionPage/_pages/chromium_base.py index 025ab24..0d51807 100644 --- a/DrissionPage/_pages/chromium_base.py +++ b/DrissionPage/_pages/chromium_base.py @@ -5,6 +5,7 @@ """ from json import loads, JSONDecodeError from os.path import sep +from pathlib import Path from re import findall, match from threading import Thread from time import perf_counter, sleep @@ -16,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 get_usable_path, raise_error +from .._functions.tools import raise_error from .._functions.web import location_in_viewport from .._units.actions import Actions from .._units.listener import Listener @@ -1021,7 +1022,7 @@ class ChromiumBase(BasePage): name = f'{name}.jpg' path = f'{path}{sep}{name}' - path = get_usable_path(path) + path = Path(path) pic_type = path.suffix.lower() pic_type = 'jpeg' if pic_type == '.jpg' else pic_type[1:] diff --git a/DrissionPage/_pages/chromium_page.py b/DrissionPage/_pages/chromium_page.py index 73777de..e01419a 100644 --- a/DrissionPage/_pages/chromium_page.py +++ b/DrissionPage/_pages/chromium_page.py @@ -162,7 +162,7 @@ class ChromiumPage(ChromiumBase): :param url: 要匹配url的文本 :param tab_type: tab类型,可用列表输入多个 :param single: 是否返回首个结果的id,为False返回所有信息 - :return: tab id或tab dict + :return: tab id或tab列表 """ return self._browser.find_tabs(title, url, tab_type, single) diff --git a/DrissionPage/_units/screencast.py b/DrissionPage/_units/screencast.py index 4b927a8..086e14c 100644 --- a/DrissionPage/_units/screencast.py +++ b/DrissionPage/_units/screencast.py @@ -33,7 +33,9 @@ class Screencast(object): self.set_save_path(save_path) if self._path is None: raise ValueError('save_path必须设置。') - clean_folder(self._path) + tmp = self._path / 'tmp' + tmp.mkdir(parents=True, exist_ok=True) + clean_folder(tmp) if self._mode.startswith('frugal'): self._page.driver.set_callback('Page.screencastFrame', self._onScreencastFrame) self._page.run_cdp('Page.startScreencast', everyNthFrame=1, quality=100)