首页 > 解决方案 > FirefoxDriver 不要使用我的代理 (geckodriver)

问题描述

我创建了这段代码,我已经解决了它没有连接到任何网站的问题,(就像打开 Firefox 浏览器但没有打开我想要的任何网站)。

我当前的问题是它不使用给定的代理。

System.setProperty("webdriver.gecko.driver", "C:\\Users\\michi\\Desktop\\insta\\geckodriver\\geckodriver.exe");

String proxy = "88.118.134.214:60737"; //got this from public proxy list
String[] split = proxy.split(":");
String proxy_ip = split[0];
String proxy_port = split[1];

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", proxy_ip);
profile.setPreference("network.proxy.http_port", proxy_port);

DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, profile);

WebDriver driver = new FirefoxDriver(dc);
driver.get("https://www.wieistmeineip.de/");

Thread.sleep(5000);
driver.quit();

现在有人如何解决这个问题吗?我应该使用其他 WebDriver 还是 smth?

先感谢您!

标签: javahttp-proxygeckodriver

解决方案


推荐阅读