Search code examples
selenium-webdriverproxyweb-scrapinghttp-proxy

Selenium Webdriver using Proxy IP


I was using selenium webdriver to scrap data from a website.due to heavy traffic from My IP, now i am not able to access website (may be my ip is blocked for the website).

Is there any way to setup the Proxy IP, so that it would be treated as a new IP every-time i run the webdriver..?


Solution

  • You can set proxy IP with selenium webdriver as per following way :

    FirefoxProfile profile = new FirefoxProfile();
    profile.addAdditionalPreference("network.proxy.http", "localhost");
    profile.addAdditionalPreference("network.proxy.http_port", "8080");
    WebDriver driver = new FirefoxDriver(profile);
    

    You should change your desired IP address and port in above code.

    For more detail , Please have a look at : Selenium Webdriver with proxy