mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
使用DownloadKit下载时如果是blob数据,改用浏览器
This commit is contained in:
parent
13821c0d75
commit
415ef28dc6
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user