【问题标题】:how to run selenium automated scripts in cpanel如何在 cpanel 中运行 selenium 自动化脚本
【发布时间】:2020-10-15 10:55:45
【问题描述】:

我开发了一个用于 selenium 自动化的 python 脚本。它会自动打开 selenium chrome 浏览器并登录到特定网站。它在本地主机服务器中完美运行。现在我按照this 教程将它部署到cpanel 服务器中。但是当我开始运行它时,它会显示500 Internal Server Error

options = Options()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--headless")
browser = webdriver.Chrome(options=options, executable_path='chromedriver')
wait = WebDriverWait(browser, 10)

上面的代码出错了。

我检查了错误日志

selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

但是chromedriver和脚本在同一个目录下 我在代码中添加了option('--headless') 请帮助我克服这个错误。 我是 cpanel 的初学者

【问题讨论】:

标签: python flask selenium-webdriver selenium-chromedriver cpanel


【解决方案1】:

默认情况下,. 例如,当前目录不在 linux/osx shell 的 PATH 中。

此外,即使是这样,python 脚本也有可能以不同于其实际位置的工作目录启动。

在执行 python 脚本之前,您需要将 chromedriver 所在的位置设置为 PATH,或者将该路径提供为绝对位置,或者在创建 Chrome 实例之前尝试定位 chromedriver 二进制文件并将其传递给 executable_path

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-10
    • 2017-09-23
    • 2011-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-04
    相关资源
    最近更新 更多