问题描述
在无头模式下,Chrome默认不允许下载文件。然而,最近他们向DevTools添加了一个选项来启用此行为:
在Python中使用Selenium和ChromeDriver,我该如何允许文件下载?
这是用于添加对无头文件下载支持的chromedriver票据:
它还引用了步骤为:
$ b
In headless mode, Chrome defaults to disallowing file downloads.
However, recently they added an option to DevTools to enable this behavior:
https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-setDownloadBehavior
Using Selenium with ChromeDriver in Python, how do I allow file downloads?
Here's the chromedriver ticket to add support for headless file downloads: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1973
It also references https://bugs.chromium.org/p/chromium/issues/detail?id=696481 which has reproduction steps for the issue:
这篇关于用Python在Selenium中下载Chrome无头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!