簡體   English   中英

Python linuxmint 二進制文件不是 Firefox 可執行文件

[英]Python linuxmint binary is not a Firefox executable

我測試了 selenium python 並且我在 firefox 中遇到了這些錯誤,我找不到解決方案這里我的代碼

from selenium import webdriver 
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
options = Options()
options.binary = FirefoxBinary(r'/usr/bin/firefox')

driver = webdriver.Firefox(executable_path= r'./scrap/geckodriver', options=options) 
driver.get("http://www.google.com") 
print (driver.page_source.encode('utf-8') )
driver.close() 

我的錯誤消息 python linuxmint:

selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable

我在論壇上搜索了幾天,但我找不到 linux mint 的解決方案!

謝謝斯蒂芬妮

這是在 Debian 上工作的 selenium/Firefox 設置的示例,它也應該在 Mint 上工作,因為它基本上是相同的操作系統:

from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options as Firefox_Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
import time as t
import pandas as pd

firefox_options = Firefox_Options()

# firefox_options.add_argument("--width=1280")
# firefox_options.add_argument("--height=720")

driverService = Service('chromedriver/geckodriver') ## path where you saved geckodriver

browser = webdriver.Firefox(service=driverService, options=firefox_options)

Selenium 文檔: https://www.selenium.dev/documentation/

現在我得到這個錯誤

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH

謝謝斯蒂芬妮

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM