我想通过 gecko 驱动程序在 Google Colab 中运行 selenium,但它告诉我:可执行文件需要位于 PATH 中
我在Google Colab中上传了firefox和gecko驱动程序并复制了gecko驱动程序的路径。该代码在我的电脑上运行良好。
google clob 中的 firefox 和 gecko 驱动程序,但出现错误。
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support import ui
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.common.exceptions import TimeoutException
driver = webdriver.Firefox(executable_path=r'content/geckodriver.exe')
WebDriverException: Message: 'content/geckodriver.exe' executable needs to be in PATH.
我希望 Google Colab 环境中的 selenium 能够识别 gecko 驱动程序。
最佳答案
我在这里提出了如何在 Colab 上使用 chrome+selenium 的要点。
https://gist.github.com/korakot/5c8e21a5af63966d80a676af0ce15067
关键是将驱动复制到PATH(这里是/usr/bin)
!cp/usr/lib/chromium-browser/chromedriver/usr/bin
您也可以尝试将 Gecko 驱动程序复制到那里。但您不能使用仅在 Windows 上运行的 exe
文件。
关于selenium - 如何在 google colab 中插入 geckodriver 的路径(环境变量)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54327654/