使用Selenium webdriver在Firefox中动态更改代理 [英] Dynamically changing proxy in Firefox with Selenium webdriver
问题描述
目前我有使用代理配置文件的代理支持,但有什么方法可以在浏览器处于运行状态时更改代理?
$
proxy = Proxy({$ b $'proxyType':'MANUAL' ,
'httpProxy':proxy_ip,
'ftpProxy':proxy_ip,
'sslProxy':proxy_ip,$ b $'noProxy':''#根据需要设置这个值
})
browser = webdriver.Firefox(proxy = proxy)
据我所知,只有两种方法来更改代理设置,一个通过配置文件),而另一个使用驱动程序的功能时,按照此处进行实例化。可悲的是,这些方法都没有做你想要的,因为它们都是在你创建驱动程序之前发生的。
我必须问,为什么要更改代理设置?我唯一可以想到的唯一解决方案就是将firefox指向可以在运行时更改的代理。我不确定,但这可能是与browsermob代理可能。
Is there any way to dynamically change the proxy being used by Firefox when using selenium webdriver?
Currently I have proxy support using a proxy profile but is there a way to change the proxy when the browser is alive and running?
My current code:
proxy = Proxy({
'proxyType': 'MANUAL',
'httpProxy': proxy_ip,
'ftpProxy': proxy_ip,
'sslProxy': proxy_ip,
'noProxy': '' # set this value as desired
})
browser = webdriver.Firefox(proxy=proxy)
Thanks in advance.
As far as I know there are only two ways to change the proxy setting, one via a profile (which you are using) and the other using the capabilities of a driver when you instantiate it as per here. Sadly neither of these methods do what you want as they both happen before as you create your driver.
I have to ask, why is it you want to change your proxy settings? The only solution I can esily think of is to point firefox to a proxy that you can change at runtime. I am not sure but that might be possible with browsermob-proxy.
这篇关于使用Selenium webdriver在Firefox中动态更改代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!