gpt4 book ai didi

python - 在 Python 中使用 Selenium 下载 Chrome headless 文件

转载 作者:太空狗 更新时间:2023-10-30 01:11:56 24 4
gpt4 key购买 nike

在 headless 模式下,Chrome 默认不允许文件下载。

但是,最近他们向 DevTools 添加了一个选项来启用此行为:

https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-setDownloadBehavior

在 Python 中将 Selenium 与 ChromeDriver 结合使用,如何允许文件下载?

最佳答案

这是添加对 headless 文件下载支持的 chromedriver 票证:https://bugs.chromium.org/p/chromedriver/issues/detail?id=1973

File downloading is disabled when using current version of headless Chrome (#60). Support to enable downloading is added to version # 62, which is currently in Dev channel. Need ChromeDriver to support this feature too.

它还引用了 https://bugs.chromium.org/p/chromium/issues/detail?id=696481其中有问题的重现步骤:

Chrome Version : Chromium 58.0.3023.0

What steps will reproduce the problem? (1) Set headless mode (--headless) on command-line (2) Point URL to downloadable file (3) Nothing happens

What is the expected result?

When launching in headless mode and pointing to an URL with a downloadable file, file should be downloaded and saved in "Downloads" folder.

What happens instead?

Nothing happens, file doesn't get downloaded.

关于python - 在 Python 中使用 Selenium 下载 Chrome headless 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46135302/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com