如何在 repl.it 上运行 chromedriver

问题描述 投票:0回答:2

我基本上想在 repl.it 上使用 selenium,但不知道该怎么做。我尝试将 chromedriver 安装到 repl.it 但仍然收到此错误:

Traceback (most recent call last):
  File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    driver = webdriver.Chrome()
  File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 90, in __init__
    self.service.start()
  File "/home/runner/dictionaryBot/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

这是我的代码

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://youtube.com")
python selenium replit
2个回答
0
投票

尝试分叉这个 Repl,它有可用的 Selenium,您可以使用:高级 Selenium 选项


0
投票

@LuisAFK 的回复目前已过时。虽然他们确实有更新的repl

https://replit.com/@LuisAFK/Selenium?v=1#README.md

请注意:我的 replit 实例认为它违反了 TOS,并阻止我分叉它,尽管我相信这是一个错误,因为我没有看到任何违反 TOS 的内容
© www.soinside.com 2019 - 2024. All rights reserved.