问题
I use Selenium webdriver for Firefox with Scrapy and now I need to change proxies dynamically but all I've found so far in docs is that I can specify proxy in profile when I instantiate webdriver itself. So it means that I can't change proxy in dynamically?
Is there any way to do that?
回答1:
selenium does not provide this kind of functionality. It is not possible to dynamically change the browser preferences/desired capabilities once you've launched the browser.
You have to close/quit the browser and start up another webdriver instance with a new proxy configuration.
See also relevant discussion:
- Modify preferences of RUNNING Firefox instance via WebDriver
来源:https://stackoverflow.com/questions/29450802/rotating-proxies-in-selenium