【发布时间】:2014-02-24 17:09:15
【问题描述】:
我设法使用下面的代码使用带有 selenium for chrome 的代理服务器:
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)
但是,我想知道是否可以在运行时将该代理更改为新代理。或者,如果有任何其他方式可以做到这一点,那么它允许我这样做。我在想使用上面的代码我必须关闭浏览器然后重新打开才能开始新会话并使用另一个代理?请帮忙:)
【问题讨论】:
-
我正在尝试在脚本中需要时将代理更改为其他代理。无需重新启动脚本。