Mae*_*cky 8 python proxy selenium
我想使用Selenium Webdriver和需要用户身份验证的代理.这可能吗?
这是,到目前为止我所拥有的,但我不知道在哪里放置凭据(用户:传递@代理:端口)
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "proxy")
profile.set_preference("network.proxy.http_port", "port_number")
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
driver.get('http://www.google.com')
driver.title
Run Code Online (Sandbox Code Playgroud)
cro*_*eaf -3
这是我一直使用的,没有任何问题,使用 Seleniums 内置的代理功能。
from selenium import webdriver
from selenium.webdriver.common.proxy import *
prof = webdriver.FirefoxProfile()
prof.set_preference('signon.autologin.proxy', 'true')
prof.set_preference('network.proxy.share_proxy_settings', 'false')
prof.set_preference('network.automatic-ntlm-auth.allow-proxies', 'false')
prof.set_preference('network.auth.use-sspi', 'false')
proxy_data = {'address': '123.123.123.123:2345',
'usernmae': 'johnsmith123',
'password': 'iliketurtles'}
proxy_dict = {'proxyType': ProxyType.MANUAL,
'httpProxy': proxy_data['address'],
'ftpProxy': proxy_data['address'],
'sslProxy': proxy_data['address'],
'noProxy': '',
'socksUsername': proxy_data['username'],
'socksPassword': proxy_data['password']}
proxy_config = Proxy(proxy_dict)
driver = webdriver.Firefox(proxy=proxy_config, firefox_profile=prof)
Run Code Online (Sandbox Code Playgroud)
编辑:这个答案来自 2017 年。Selenium 和 Firefox 都做出了重大更改,并且不再有效。因此,为什么这个答案从 5 票变成了现在的 -3 票。
| 归档时间: |
|
| 查看次数: |
3963 次 |
| 最近记录: |