您可以通过
chrome://downloads/使用驱动程序进行导航来获取每次下载的状态。
要等待所有下载完成并列出所有路径,请执行以下操作:
def every_downloads_chrome(driver): if not driver.current_url.startswith("chrome://downloads"): driver.get("chrome://downloads/") return driver.execute_script(""" var items = downloads.Manager.get().items_; if (items.every(e => e.state === "COMPLETE")) return items.map(e => e.fileUrl || e.file_url); """)# waits for all the files to be completed and returns the pathspaths = WebDriverWait(driver, 120, 1).until(every_downloads_chrome)print(paths)


