From e4e1affd4394c6e6df8392e211f8d4c9eb8d4928 Mon Sep 17 00:00:00 2001 From: g1879 Date: Thu, 17 Oct 2024 17:35:50 +0800 Subject: [PATCH] =?UTF-8?q?4.1.0.9=E4=BC=98=E5=8C=96=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/__init__.py | 2 +- DrissionPage/_base/base.py | 2 +- DrissionPage/_pages/chromium_page.py | 4 ++++ DrissionPage/_pages/web_page.py | 4 ++++ DrissionPage/_units/clicker.py | 2 +- DrissionPage/_units/setter.py | 10 +++++++--- requirements.txt | 2 +- setup.py | 2 +- 8 files changed, 20 insertions(+), 8 deletions(-) diff --git a/DrissionPage/__init__.py b/DrissionPage/__init__.py index a7fc44d..4d2b44b 100644 --- a/DrissionPage/__init__.py +++ b/DrissionPage/__init__.py @@ -12,4 +12,4 @@ from ._pages.chromium_page import ChromiumPage from ._pages.session_page import SessionPage from ._pages.web_page import WebPage -__version__ = '4.1.0.8' +__version__ = '4.1.0.9' diff --git a/DrissionPage/_base/base.py b/DrissionPage/_base/base.py index 8132f4c..b29bd7c 100644 --- a/DrissionPage/_base/base.py +++ b/DrissionPage/_base/base.py @@ -296,7 +296,7 @@ class BasePage(BaseParser): if self._DownloadKit is None: if not self._session: self._create_session() - self._DownloadKit = DownloadKit(driver=self, goal_path=self.download_path) + self._DownloadKit = DownloadKit(driver=self, save_path=self.download_path) return self._DownloadKit def _before_connect(self, url, retry, interval): diff --git a/DrissionPage/_pages/chromium_page.py b/DrissionPage/_pages/chromium_page.py index f8e6573..00d1847 100644 --- a/DrissionPage/_pages/chromium_page.py +++ b/DrissionPage/_pages/chromium_page.py @@ -96,6 +96,10 @@ class ChromiumPage(ChromiumBase): def address(self): return self.browser.address + @property + def download_path(self): + return self.browser.download_path + def save(self, path=None, name=None, as_pdf=False, **kwargs): return save_page(self, path, name, as_pdf, kwargs) diff --git a/DrissionPage/_pages/web_page.py b/DrissionPage/_pages/web_page.py index bfe1966..a8b8c6a 100644 --- a/DrissionPage/_pages/web_page.py +++ b/DrissionPage/_pages/web_page.py @@ -112,6 +112,10 @@ class WebPage(SessionPage, ChromiumPage, BasePage): def timeout(self): return self.timeouts.base if self._d_mode else self._timeout + @property + def download_path(self): + return self.browser.download_path + def get(self, url, show_errmsg=False, retry=None, interval=None, timeout=None, **kwargs): if self._d_mode: return super(SessionPage, self).get(url, show_errmsg, retry, interval, timeout) diff --git a/DrissionPage/_units/clicker.py b/DrissionPage/_units/clicker.py index 617f1d6..1985d61 100644 --- a/DrissionPage/_units/clicker.py +++ b/DrissionPage/_units/clicker.py @@ -125,7 +125,7 @@ class Clicker(object): if not self._ele.tab._browser._dl_mgr._running: self._ele.tab._browser.set.download_path('.') - if new_tab: + if new_tab or self._ele.tab._type.endswith('Page'): obj = browser = self._ele.tab._browser tid = 'browser' t_settings = TabDownloadSettings(self._ele.owner.tab_id) diff --git a/DrissionPage/_units/setter.py b/DrissionPage/_units/setter.py index b9b96e6..f3243af 100644 --- a/DrissionPage/_units/setter.py +++ b/DrissionPage/_units/setter.py @@ -51,7 +51,7 @@ class SessionPageSetter(BaseSetter): def download_path(self, path): super().download_path(path) if self._owner._DownloadKit: - self._owner._DownloadKit.set.goal_path(self._owner._download_path) + self._owner._DownloadKit.set.save_path(self._owner._download_path) def timeout(self, second): self._owner._timeout = second @@ -230,7 +230,7 @@ class TabSetter(ChromiumBaseSetter): super().download_path(path) self._owner.browser._dl_mgr.set_path(self._owner, self._owner._download_path) if self._owner._DownloadKit: - self._owner._DownloadKit.set.goal_path(self._owner._download_path) + self._owner._DownloadKit.set.save_path(self._owner._download_path) def download_file_name(self, name=None, suffix=None): self._owner.browser._dl_mgr.set_rename(self._owner.tab_id, name, suffix) @@ -263,8 +263,12 @@ class ChromiumPageSetter(TabSetter): self._owner.browser.retry_interval = interval def download_path(self, path): - super().download_path(path) + if path is None: + path = '.' + self._owner._download_path = str(Path(path).absolute()) self._owner.browser.set.download_path(path) + if self._owner._DownloadKit: + self._owner._DownloadKit.set.save_path(path) def download_file_name(self, name=None, suffix=None): self._owner.browser.set.download_file_name(name, suffix) diff --git a/requirements.txt b/requirements.txt index eb29ca6..5706df4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ requests lxml cssselect -DownloadKit>=2.0.4 +DownloadKit>=2.0.5 websocket-client click tldextract diff --git a/setup.py b/setup.py index 2a8649c..b846836 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setup( 'lxml', 'requests', 'cssselect', - 'DownloadKit>=2.0.4', + 'DownloadKit>=2.0.5', 'websocket-client', 'click', 'tldextract',