将 Python seleniumwire 与代理身份验证一起使用

时间:2021-05-26 09:08:27

标签: python selenium geckodriver seleniumwire

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

我发现了一个使用代理身份验证的包: 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

有人知道如何克服这个错误吗?

感谢您的关注

0 个答案:

没有答案