Faz*_*lut 6 python firefox proxy selenium
我在用:
我需要验证当前项目的用户名和密码。我已经日以继夜地工作了几天,我无法解决这个问题。我在互联网上找到了一些扩展,但它是 13 年的,我想这就是它不起作用的原因。您还可以在下面看到我尝试过的其他方法。
但不起作用,因为由于 Selenium 错误,代理身份验证不再起作用。
alert_popup = browser.switch_to_alert()
alert_popup.send_keys(
"{username}{tab}{password}{tab}".format(
username=proxy_username, tab=Keys.TAB, password=proxy_password
)
)
alert_popup.accept()
Run Code Online (Sandbox Code Playgroud)
我想创建一个配置文件并手动保存代理信息并使用该配置文件启动 selenium。但是,firefox 不允许手动输入用户名和密码。
要在 python selenium 中使用带有身份验证的代理,您可以使用 seleniumwire。
首先,使用 pip install selenium-wire 安装它
然后从seleniumwire导入webdriver而不是selenium
在这里查看原始答案
from seleniumwire import webdriver
options = {
'proxy': {
'http': 'http://username:password@host:port',
'https': 'https://username:password@host:port',
'no_proxy': 'localhost,127.0.0.1' # excludes
}
}
browser = webdriver.Chrome(path_to_driver, seleniumwire_options=options)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3616 次 |
最近记录: |