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

Selenium Wire使用认证代理时抛出无效服务器规范错误

解决Selenium Wire配置认证代理的"无效服务器规范"错误
  • 问题根源是代理URL的写法不符合Selenium Wire的要求,带身份验证的代理不能将用户名密码直接嵌入HTTP/HTTPS的URL字符串中,需要单独配置认证字段。
  • 修改后的正确代码:
from proxy import getProxy
from seleniumwire import webdriver
import time

username, password, ip, port = getProxy()

options = {
    'proxy': {
        'http': f"http://{ip}:{port}",
        'https': f"https://{ip}:{port}",
        'no_proxy': 'localhost,127.0.0.1',
        'username': username,
        'password': password
    }
}

driver = webdriver.Chrome(executable_path='chromedriver.exe', seleniumwire_options=options)

driver.get('http://whatismyipaddress.com')

time.sleep(8)

driver.quit()
  • 关键改动:移除URL中的{username}:{password}@部分,新增username和password两个独立配置项,让Selenium Wire能正确识别代理服务器的认证信息与地址规范。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 13:50:25