首页 > 解决方案 > 将 Python seleniumwire 与代理身份验证一起使用

问题描述

我正在尝试使用带有用户名和密码的代理身份验证访问 url。

我找到了一个使用代理身份验证的包: selenium-wirehttps://github.com/wkeeling/selenium-wire

我写了以下代码

from seleniumwire import webdriver

df_proxies=WebShare_Proxies()
args=df_proxies.values[random.choice(df_proxies.index)].tolist()

proxy_ip,proxy_port,username,password=args

url='https://fra.privateinternetaccess.com/pages/whats-my-ip/'

proxyString=username+":"+password+"@"+str(proxy_ip)+":"+str(proxy_port)

options = {
'proxy': {
    'http': 'http://'+proxyString,
    'https': 'https://'+proxyString,
    'no_proxy': 'localhost,127.0.0.1'
    }
}

driver = webdriver.Firefox(seleniumwire_options=options)

WebShare_Proxies()调用https://www.webshare.io/ API 来获取我的代理列表 我的代理使用用户名和密码进行身份验证

proxyString
'$myusername:$mypassword@45.95.96.187:8746'

调用时出现以下错误webdriver.Firefox(seleniumwire_options=options)

...in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

任何人都知道如何克服这个错误?

谢谢你的考虑

标签: pythonseleniumgeckodriverseleniumwire

解决方案


推荐阅读