简体   繁体   English

Selenium Chrome Headless 下载文件

[英]Selenium Chrome Headless download file

I use headless chrome and selenium but i have problem in downloading file.我使用无头铬和硒,但我在下载文件时遇到问题。 Using options:使用选项:

prefs = {"download.default_directory": dr,
         "download.prompt_for_download": False,
         "download.directory_upgrade": True,
         "safebrowsing.enabled": True
         }
options.add_experimental_option("prefs", prefs)

If headless chrome not used then file download successfully but if headless works then nothing actions.如果未使用无头 chrome,则文件下载成功,但如果无头工作,则没有任何操作。 How i can solve it?我该如何解决?

Your question is already answered at https://stackoverflow.com/a/42583255/6304901您的问题已在https://stackoverflow.com/a/42583255/6304901 上得到解答

It's not a bug it's a feature :这不是一个错误,它是一个功能

We most likely want to this to be something you need to either control or enable via DevTools to avoid letting random websites drop files on your disk just because you're running in headless mode.我们很可能希望这是您需要通过 DevTools 控制或启用的东西,以避免让随机网站仅仅因为您在无头模式下运行而将文件放在您的磁盘上。

please see https://bugs.chromium.org/p/chromium/issues/detail?id=696481 for further details请参阅https://bugs.chromium.org/p/chromium/issues/detail?id=696481了解更多详情

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM