chrome动态ip python
import org.json.JSONException;
import org.json.JSONObject;
import org.openqa.selenium.Platform;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.gargoylesoftware.htmlunit.DefaultCredentialsProvider;
import com.gargoylesoftware.htmlunit.WebClient;
public class FirefoxDriverProxyDemo
{
chrome动态ip python// 代理隧道验证信息
final static String proxyUser = “H01234567890123D”;
final static String proxyPass = “0123456789012345”;
// 代理服务器
final static String proxyHost = “http-dyn.abuyun.com”;
final static int proxyPort = 9020;
final static String firefoxBin = “D:/Program Files/Mozilla Firefox/firefox.exe”;
public static void main(String[] args) throws JSONException
{
System.setProperty(“webdriver.firefox.bin”, firefoxBin);
FirefoxProfile profile = new FirefoxProfile();
// 使用代理
profile.setPreference(“network.proxy.type”, 1);
profile.setPreference(“network.proxy.http”, proxyHost);
profile.setPreference(“network.proxy.http_port”, proxyPort);
profile.setPreference(“network.proxy.ssl”, proxyHost);
profile.setPreference(“network.proxy.ssl_port”, proxyPort);
profile.setPreference(“username”, proxyUser);
profile.setPreference(“password”, proxyPass);
// 所有协议公用一种代理配置,如果单独配置,这项设置为false
profile.setPreference(“network.proxy.share_proxy_settings”, true);
// 对于localhost的不用代理,这里必须要配置,否则无法和webdriver通讯
profile.setPreference(“network.proxy.no_proxies_on”, “localhost”);
// 以代理方式启动firefox
FirefoxDriver driver = new FirefoxDriver(profile);
}
}

阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。