[英]Errror with using Selenium Webdriver with chrome
from bs4 import BeautifulSoup, SoupStrainer
from selenium import webdriver
from selenium.webdriver import chrome
from selenium.webdriver.chrome.options import Options
url = 'https://...'
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument("--headless")
driver = webdriver.Chrome('path')
driver.get(url)
錯誤:
Traceback (most recent call last):
File "", line 20, in <module>
driver.get(EPL_url)
File "", line 333, in get
self.execute(Command.GET, {'EPL_url': url})
File "", line 321, in execute
self.error_handler.check_response(response)
File "", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown command: unknown command: session/9df33bd6f0e57084300c81738cf6c2d5/EPL_url
我試圖查看所有潛在的錯誤,但一無所獲。 煩人的事情是,“driver.get()”function 早些時候工作得很好。 在我更改了 URL 的變量名之后,它似乎才被打亂了。 我真的不知道該怎么做,需要讓這段代碼恢復運行。 請幫助我解決上述錯誤,以便我糾正它。! 將不勝感激。
此問題可能是由於 chrome 驅動程序的路徑。 這里有一個更簡單的解決方案:安裝python-chrome驅動package,在你的腳本中導入,就大功告成了。
一步步:
from selenium import webdriver
import chromedriver_binary # Adds chromedriver binary to path
driver = webdriver.Chrome()
driver.get("http://www.python.org")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.