You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Colab中Selenium的chromedriver意外退出错误求助

Google Colab中Selenium的chromedriver意外退出错误求助

我之前在Google Colab上用Selenium写的爬虫一直正常运行,但现在突然不行了,实在搞不懂哪里出问题了😭

我的代码如下:

# 依赖安装
!pip install selenium
!apt-get update
!apt install chromium-chromedriver
!pip install fake-useragent

from selenium import webdriver
from fake_useragent import UserAgent

# ChromeDriver配置选项
ua = UserAgent()
userAgent = ua.random

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

driver = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
chrome_options.add_argument('--user-agent="'+userAgent+'"')

运行这段代码后,Colab抛出了如下错误:

"Message: Service chromedriver unexpectedly exited. Status code was: 1"

我已经在相关话题里找过各种解决方案,但都不管用。之前看到有提到过问题的根源:

这个问题是Colab系统从Ubuntu 18.04升级到20.04 LTS导致的——Ubuntu 20.04 LTS下,Google Colab不再通过snap包之外的方式分发chromium-browser了...

有没有大佬知道,现在还能在Google Colab上正常使用Selenium的解决办法呀?

备注:内容来源于stack exchange,提问作者Alejandro Romero López

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 15:14:06