she*_*ida 5 firefox selenium path geckodriver google-colaboratory
我想通过 Gecko 驱动程序在 Google Colab 中运行 selenium,但它告诉我:可执行文件需要在 PATH 中
我在 Google Colab 中上传了 firefox 和 gecko 驱动程序并复制了 gecko 驱动程序的路径。该代码在我的 PC 上运行良好。
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.
Run Code Online (Sandbox Code Playgroud)
我希望在 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 驱动程序复制到那里。但您不能使用exe仅在 Windows 上运行的文件。
| 归档时间: |
|
| 查看次数: |
5050 次 |
| 最近记录: |