我试图在google colab上使用selenium,然后发生了一个错误。错误消息是错误的 "chromedriver' executable needs to be in PATH."
我在谷歌上搜索,找到了一个解决方案。解决办法如下:
!apt-get update
!apt install chromium-chromedriver
!cp /usr/lib/chromium-browser/chromedriver /usr/bin
!pip install selenium
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('chromedriver',options=options)
当我取下 --headless
选项时,发生以下错误。
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
如果没有 --headless
选项
1条答案
按热度按时间eoxn13cs1#
不,没有。
Google colab
是为了--headless
模式您不能简单地调用真实浏览器的对象。