g1879 / DrissionPage

Python based web automation tool. Powerful and elegant.
https://DrissionPage.cn/
BSD 3-Clause "New" or "Revised" License
8.24k stars 778 forks source link

下载文件功能有问题,传入的地址和实际下载地址不对,下载报错 #397

Open HertJ opened 1 month ago

HertJ commented 1 month ago
def set_path(self, tab, path):
    tid = tab if isinstance(tab, str) else tab.tab_id

    TabDownloadSettings(tid).path = path
    if not self._running or tid == 'browser':
        self._browser._driver.set_callback('Browser.downloadProgress', self._onDownloadProgress)
        self._browser._driver.set_callback('Browser.downloadWillBegin', self._onDownloadWillBegin)
        r = self._browser._run_cdp('Browser.setDownloadBehavior', downloadPath=self._browser._download_path,
                                   behavior='allowAndName', eventsEnabled=True)

这里的self._browser._download_path 与我传入path 不一致

HertJ commented 1 month ago

page.set.download_path('./tmp/123') # 设置文件保存路径

page.get('https://office.qq.com/download.html') 实际下载的文件在我脚本运行目录,也就是./

HertJ commented 1 month ago

version 是 4.1.0.5