I am working on a bot. I want the bot to change the proxy of the webdriver every 50 searches. I have an API that requests the proxy and the socket, i store those variables and so far i have been using firefox profiles to set it up but that doesnt work very well.
So given the fact that i already have a viable source of proxies and ports, can you tell me any way i can change the proxy without crashing the webdriver and doing it on a single session?
Previous attempts:
I tried setting up a firefox profile this way:
regions = {
'US': '', #USA is the default server
'Australia': #json response through the api,
'Canada': #json response through the api,
'France': #json response through the api,
'Germany': #json response through the api,
'UK': #json request response the api
}
for region in regions:
fp = webdriver.FirefoxProfile()
if(regions[region] != ''):
fp.set_preference("network.proxy.type", 1)
fp.set_preference("network.proxy.socks", regions[region])
fp.set_preference("network.proxy.socks_port", port)
This caused me some problems and i had to start a new session each time i wanted to swap a proxy. So i tried to change the proxy through the Firefox options (options - general - connection settings) but turns out the popup that appears on the screen after clicking the connection settings button is not accessible through selenium or javascript (xul file).
from How to change proxy on my webdriver multiple times on a single session?
No comments:
Post a Comment