Selenium (Python) - Changing Proxy During Runitime? -


i managed use proxy server selenium chrome using code below:

chromedriver = "c:/seltests/chromedriver" os.environ["webdriver.chrome.driver"] = chromedriver chrome_options = webdriver.chromeoptions() chrome_options.add_argument('--proxy-server=141.0.175.141:443') driver = webdriver.chrome(chrome_options=chrome_options) 

however, know if possible change proxy new 1 during run-time. or if there other way of doing allows me to. i'm thinking using code above have have browser close re-open start new session , use proxy? please :)

you have re-launch browser instance in order achieve this. wherever want change proxy insert following code:

driver.quit() chrome_options = webdriver.chromeoptions() chrome_options.add_argument('--proxy-server=<new proxy>') driver = webdriver.chrome(chrome_options=chrome_options) 

this close current browser , launch new 1 new proxy.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -