Change IP address in selenium
11,491
You can use proxy settings if you have access to a proxy you can connect to.
http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#using-a-proxy
String PROXY = "localhost:8080";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new InternetExplorerDriver(cap);
Related videos on Youtube
Author by
user5964275
Updated on June 04, 2022Comments
-
user5964275 almost 2 years
I am in Canada and want to use Selenium to scrape data from a Chinese website. However, since my IP is in Canada, I was always redirected to the Canada site which is different from its orginal Chinese site. How could I visit the original version of the site (which is shown to Chinese)? In other words, how can I pretend that I have a China based IP? Is there a way without having to buy a VPN?
-
Florent B. almost 8 yearsAre you sure that the redirection is based on the IP and not on the language in the http headers sent by your browser?
-
-
user5964275 almost 8 yearsI don't have a Proxy. Is that necessary?
-
David Lai almost 8 yearsPretty much need a proxy, or a VPN. IP address is done below the application level (network layer).
-
teller.py3 about 5 years@DavidLai hey david you are interested in talking in private about vpn/ip with selenium?