【发布时间】:2019-12-04 10:36:49
【问题描述】:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'/usr/local/bin/google-chrome')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
我收到此错误:
File "test.py", line 5, in <module>
driver = webdriver.Chrome(executable_path=r'/usr/bin/google-chrome')
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: 1
我尝试了互联网上的其他解决方案,但我尝试的每个解决方案都收到了一个新错误。我只想使用 python selenium 和 chrome 驱动程序获取页面源,我不知道为什么没有适合我的解决方案,有什么帮助吗?
我在客户端-服务器中执行此操作,在我的本地即时通讯中使用 windows 并且它的工作良好,但是它的代码不同......
【问题讨论】:
-
executable_path=r'/usr/local/bin/google-chrome'应该是 chrome 驱动程序而不是 chrome 的路径。您可以从chromedriver.chromium.org/downloads 获取适用于您的 Chrome 版本的 chrome 驱动程序。 -
我这样做了但仍然无法正常工作,现在我遇到了这个错误:未知错误:Chrome 无法启动:异常退出
-
您的 Chrome 版本和 Chromedriver 版本是否匹配?这可能会有所帮助github.com/SeleniumHQ/selenium/issues/4961
-
是的@TekNath ....
标签: python selenium google-chrome selenium-webdriver selenium-chromedriver