我期待浏览器显示代理值,但它显示了我的实际IP。知道为什么吗?
“”“
FirefoxOptions options = new FirefoxOptions();
options.addPreference("network.proxy.type", 1);
options.addPreference("network.proxy.https", "151.253.165.70");
options.addPreference("network.proxy.https_port", 8080);
options.addPreference("network.proxy.https_remote_dns", true);
WebDriver driver = new FirefoxDriver(options);
driver.get("https://www.whatismyip.com");
“”“
发布于 2020-04-26 20:21:38
您可以使用firefoxprofile或选项。为由Https使用的代理添加SSL。options.addPreference("network.proxy.ssl","151.253.165.70");options.addPreference("network.proxy.ssl_port",8080);
FirefoxOptions options = new FirefoxOptions();
options.addPreference("network.proxy.type", 1);
options.addPreference("network.proxy.https", "151.253.165.70");
options.addPreference("network.proxy.https_port", 8080);
options.addPreference("network.proxy.https_remote_dns", true);
options.addPreference("network.proxy.ssl", "151.253.165.70");
options.addPreference("network.proxy.ssl_port", 8080);
WebDriver driver = new FirefoxDriver(options);
driver.get("https://www.whatismyip.com");
如果您正在使用配置文件
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "151.253.165.70");
profile.setPreference("network.proxy.http_port", 8080);
profile.setPreference("network.proxy.https", "151.253.165.70");
profile.setPreference("network.proxy.https_port", 8080);
profile.setPreference("network.proxy.ssl", "151.253.165.70");
profile.setPreference("network.proxy.ssl_port", 8080);
profile.setPreference("network.proxy.https_remote_dns", true);
https://stackoverflow.com/questions/61432210
复制