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

undetected-chromedriver问题:导航网页时浏览器崩溃

undetected-chromedriver导航崩溃白屏问题排查与解决

可能原因及对应解决方案

1. Chrome版本与库版本不兼容

undetected-chromedriver对Chrome版本依赖严格,版本不匹配会导致启动后运行异常。

  • 先查看本地Chrome版本:打开Chrome,输入chrome://version/获取版本号(比如114.0.5735.90)
  • 安装对应版本的库:执行pip install undetected-chromedriver==对应版本号
  • 或在代码中指定主版本自动匹配:
    import time
    import undetected_chromedriver as uc
    
    # 替换version_main为你的Chrome主版本号(如114、115)
    driver = uc.Chrome(version_main=114)
    
    driver.get('https://www.google.com')
    time.sleep(5)
    

2. 默认配置触发反爬拦截

默认ChromeOptions缺少规避反爬的关键参数,导致网站拦截请求,表现为白屏崩溃。

  • 修改代码添加规避参数:
    import time
    import undetected_chromedriver as uc
    
    options = uc.options.ChromeOptions()
    # 添加反爬规避参数
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--disable-blink-features=AutomationControlled')
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    
    driver = uc.Chrome(options=options)
    # 移除浏览器的webdriver标识
    driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
    
    driver.get('https://www.google.com')
    time.sleep(5)
    

3. 系统环境限制

  • 关闭杀毒软件/防火墙,检查是否拦截Chrome进程
  • Linux/macOS下避免用root用户运行脚本(会触发Chrome安全机制)
  • 启用隐身模式隔离缓存:在options中添加options.add_argument('--incognito')

内容的提问来源于stack exchange,提问作者Abdul Hossein Charkhi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 02:04:52