From 415ef28dc639a485ca23a46ca990e6b7931ee752 Mon Sep 17 00:00:00 2001 From: g1879 Date: Wed, 22 Feb 2023 19:20:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8DownloadKit=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=97=B6=E5=A6=82=E6=9E=9C=E6=98=AFblob=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E7=94=A8=E6=B5=8F=E8=A7=88=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/action_chains.py | 2 +- DrissionPage/chromium_page.py | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/DrissionPage/action_chains.py b/DrissionPage/action_chains.py index 08743ba..cfb9dc5 100644 --- a/DrissionPage/action_chains.py +++ b/DrissionPage/action_chains.py @@ -160,7 +160,7 @@ class ActionChains: :return: self """ if on_ele: - self.move_to(on_ele.locations.click_point) + self.move_to(on_ele) self._dr.Input.dispatchMouseEvent(type='mousePressed', button=button, clickCount=1, x=self.curr_x, y=self.curr_y, modifiers=self.modifier) return self diff --git a/DrissionPage/chromium_page.py b/DrissionPage/chromium_page.py index 7c4e9c5..d135056 100644 --- a/DrissionPage/chromium_page.py +++ b/DrissionPage/chromium_page.py @@ -532,12 +532,20 @@ class ChromiumDownloadSetter(DownloadSetter): def _download_by_DownloadKit(self, **kwargs): """拦截浏览器下载并用downloadKit下载""" - self._page.browser_driver.Browser.cancelDownload(guid=kwargs['guid']) - self._page.download.add(file_url=kwargs['url'], goal_path=self._page.download_path, - rename=kwargs['suggestedFilename']) - if self._download_th is None or not self._download_th.is_alive(): - self._download_th = Thread(target=self._wait_download_complete, daemon=False) - self._download_th.start() + url = kwargs['url'] + if url.startswith('blob:'): + self._page.browser_driver.Browser.setDownloadBehavior(behavior='allow', eventsEnabled=True, + downloadPath=self._page.download_path) + sleep(2) + self._page.browser_driver.Browser.setDownloadBehavior(behavior='deny', eventsEnabled=True) + else: + self._page.browser_driver.Browser.cancelDownload(guid=kwargs['guid']) + self._page.download.add(file_url=url, goal_path=self._page.download_path, + rename=kwargs['suggestedFilename']) + if self._download_th is None or not self._download_th.is_alive(): + self._download_th = Thread(target=self._wait_download_complete, daemon=False) + self._download_th.start() + if self._waiting_download: self._download_begin = True