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

Chrome 116不兼容Seleniumwire,求代理认证替代方案或更新时间

关于Seleniumwire适配Chrome 116及替代代理认证方案的解答

一、Seleniumwire的更新时间说明

  • Seleniumwire作为第三方开源库,更新节奏由维护团队把控,没有固定的更新时间表。
  • 你可以查看项目的GitHub仓库Release页面或Issues板块,关注是否有适配Chrome 116+版本的计划。这类兼容性问题通常会被社区优先反馈,维护团队会根据需求优先级推进适配工作。

二、无需Seleniumwire实现代理认证的方法

方法1:用Chrome扩展自动处理代理认证

你可以自己制作一个轻量的Chrome扩展,自动完成代理的认证请求,步骤如下:

  1. 创建扩展文件结构:
    proxy-auth-extension/
    ├── manifest.json
    └── background.js
    
  2. 编写manifest.json:
    {
        "manifest_version": 3,
        "name": "Proxy Auth Helper",
        "version": "1.0",
        "permissions": ["proxy", "storage", "webRequest", "webRequestAuthProvider"],
        "background": {
            "service_worker": "background.js"
        },
        "host_permissions": ["<all_urls>"]
    }
    
  3. 编写background.js(替换成你自己的代理和认证信息):
    const proxyConfig = {
        mode: "fixed_servers",
        rules: {
            singleProxy: {
                scheme: "http",
                host: "你的代理地址",
                port: 你的代理端口
            },
            bypassList: ["localhost"]
        }
    };
    
    chrome.proxy.settings.set({value: proxyConfig, scope: "regular"}, () => {});
    
    chrome.webRequest.onAuthRequired.addListener(
        (details, callbackFn) => {
            callbackFn({
                authCredentials: {
                    username: "你的代理用户名",
                    password: "你的代理密码"
                }
            });
        },
        {urls: ["<all_urls>"]},
        ["blocking"]
    );
    
  4. 在Selenium中加载该扩展:
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    chrome_options = Options()
    # 替换为你创建的扩展文件夹的绝对路径
    chrome_options.add_argument(r'--load-extension=D:/path/to/proxy-auth-extension')
    
    driver = webdriver.Chrome(options=chrome_options)
    driver.get("https://example.com")
    

方法2:用中间代理中转(如mitmproxy)

通过mitmproxy作为中间层,让Chrome连接mitmproxy,再由mitmproxy连接目标代理并处理认证:

  1. 安装mitmproxy:pip install mitmproxy
  2. 编写mitmproxy脚本(proxy_auth.py):
    from mitmproxy import http
    
    class ProxyAuth:
        def request(self, flow: http.HTTPFlow) -> None:
            # 设置目标代理
            flow.live.change_upstream_proxy_server(("你的代理地址", 你的代理端口))
            # 需自行生成Base64编码:将"用户名:密码"字符串转成Base64格式
            flow.request.headers["Proxy-Authorization"] = "Basic 你的Base64编码串"
    
    addons = [ProxyAuth()]
    
  3. 启动mitmproxy:mitmdump -s proxy_auth.py
  4. 在Selenium中配置连接mitmproxy:
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    chrome_options = Options()
    chrome_options.add_argument('--proxy-server=http://localhost:8080')
    # 可忽略证书错误,或提前将mitmproxy的CA证书安装到Chrome中
    chrome_options.add_argument('--ignore-certificate-errors')
    
    driver = webdriver.Chrome(options=chrome_options)
    driver.get("https://example.com")
    

    提示:首次运行mitmproxy会生成CA证书,需将证书安装到系统或Chrome中,否则会出现证书验证失败问题。

内容的提问来源于stack exchange,提问作者ZentyNhan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 18:52:43