我在加拿大,想用硒从一个中文网站上抓取数据。然而,由于我的IP在加拿大,我总是被重定向到加拿大的网站,这与它原来的中文网站不同。我怎样才能访问网站的原始版本(显示给中文)?换句话说,我如何才能假装我有一个基于中国的知识产权?有没有一种不需要购买VPN的方法?
发布于 2016-05-27 09:56:11
如果您有权访问可以连接到的代理,则可以使用代理设置。
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);https://stackoverflow.com/questions/37473580
复制相似问题