[英]Python selenium WebDriverException: chrome not reachable while opening 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.