Reputation: 1487
driver = webdriver.Firefox()
for x in range(10):
driver.get("mysite.com")
Is there a way to change the proxy on every connection to "mysite.com" in the range 10, but without closing the driver and reopening it, but just changing the settings of proxy?
Upvotes: 2
Views: 2289
Reputation: 17553
You need to import the following:
from selenium.webdriver.common.proxy import *
Then setup the proxies:
myProxy = "xx.xx.xx.xx:xxxx"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy': '' # set this value as desired
})
Then call the webdriver.Firefox() function as follows:
driver = webdriver.Firefox(proxy=proxy)
driver.get("http://www.google.com")
Or you can use tor browser it will switch the proxy automatically
Upvotes: 5