簡體   English   中英

Python Selenium ChromeDriver 無法訪問

[英]Python Selenium ChromeDriver Not Reachable

所以我無法弄清楚為什么我會得到這個異常。 當我單獨運行 chromedriver 時,我得到:

在端口 9515 上啟動 ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3)

當我嘗試從文件運行它時,我得到:

WebDriverException:消息:chrome 無法訪問(驅動程序信息:chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Linux 3.13.0-52-generic x86_64)

編碼:

if self.proxy:
    chrome_options = Options()
    chrome_options.add_argument("--proxy-server=http://user:password@proxy.com:8080")
    self.webdriver = webdriver.Chrome('/usr/bin/google-chrome', chrome_options=chrome_options)
else:
    self.webdriver = webdriver.Chrome('/usr/bin/google-chrome')

我在沒有代理的情況下運行它。 如果我不提供路徑,由於某種原因它將無法找到 chrome 二進制文件。 不知道我應該從這里去哪里。

您需要在第一個 positional 或executable_path關鍵字參數中指定的路徑是 chromedriver 的路徑,而不是 chrome 本身

self.webdriver = webdriver.Chrome('/path/to/chromedriver', chrome_options=chrome_options)

如果chromedriver$PATH - 您根本不需要指定路徑 - 通常是這種情況。

下載chrome 驅動程序並使用此代碼

driver = webdriver.Chrome("C:\\chromedriver.exe")

暫無
暫無

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

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