最近在调研代理平台的质量,需要尝试selenium接入代理,所以对收集的资料进行总结. selemiun使用java开发,浏览器使用firefoxdriver.
FirefoxDriver使用
String proxyIp = "1.1.1.11"; //代理ip,具体对应实际ip
int proxyPort = 9020; //代理ip端口
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", proxyIp);
profile.setPreference("network.proxy.http_port", proxyPort);
profile.setPreference("network.proxy.ssl", proxyIp);
profile.setPreference("network.proxy.ssl_port", proxyPort);
profile

本文总结了使用Selenium的FirefoxDriver接入代理IP的方法,包括Basic Auth身份认证的四种策略:在FirefoxProfile中设置、添加authtoken、在URL中包含凭证,以及处理弹窗认证。同时介绍了如何在火狐浏览器中查看代理设置,并提供了相关参考资料。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



