python-3.x - 无法在 linux 操作系统上使用 python selenium 和 chromedriver 下载文件

标签 python-3.x amazon-ec2 selenium-chromedriver

我正在尝试使用带有 chromedriver 和 python3 的 Selenium 下载文件。我的代码在 Windows 操作系统上完美运行,但是当我尝试在亚马逊 EC2 上执行相同的代码时,一切都很好,没有错误,找到了所有元素,但没有文件下载到特定目录? 我正在使用下面的代码,知道吗?

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()  

prefs = {"download.default_directory" : '/my_directory/'}
chrome_options.add_experimental_option("prefs",prefs)
chrome_options.add_argument('--headless')
browser= webdriver.Chrome(options=chrome_options)

最佳答案

我知道这并不能完全回答您的问题,但请尝试查看: https://github.com/21buttons/pychromeless#downloading-files

我遇到了和你一样的问题,一直没有解决。但由于我的任务将每周运行一次,所以我决定使用 AWS Lambda 并找到了这个解决方案。我希望这对您的探索有所帮助!

关于python-3.x - 无法在 linux 操作系统上使用 python selenium 和 chromedriver 下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62032558/

相关文章:

java - AWS Lambda 在图层中找不到共享对象文件

javascript - Chrome 的 AutoSelectCertificateForUrls 仅在非 headless 模式下工作

Python 3 : write method vs. os.write 返回的字节数

python-3.x - 如何发送多个收件人sendgrid V3 api Python

python - 如何找到当前函数的名称?

Elasticsearch/Logstash 错误 : com. mysql.jdbc.Driver 未加载 - 无法在服务器上找到 mysql-connector-java-5.1.36-bin.jar

windows-server-2008 - 带有 Windows 2008 R2 的亚马逊 EC2

python - 在 Python 中,如何以随机顺序打印文本文件中的行?

amazon-ec2 - 您如何在Amazon Linux上编译Pango?

python - Selenium webdriver 在 chrome ://downloads 找不到元素