在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
本来在找IWebDriver使用代理的方法,偶然获知这种的,记录并且共享
1 WebProxy proxyObject = new WebProxy("125.31.19.26", 80);//str为IP地址 port为端口号 代理类 2 HttpWebRequest Req = (HttpWebRequest)WebRequest.Create("http://ip.chemdrug.com/"); // 61.183.192.5 5 Req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; QQWubi 133; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; CIBA; InfoPath.2)"; 6 Req.Proxy = proxyObject; //设置代理 8 Req.Method = "GET"; 9 HttpWebResponse Resp = (HttpWebResponse)Req.GetResponse(); 10 string StringSub = ""; 11 string OkStr = ""; 12 Encoding code = Encoding.GetEncoding("gb2312"); 13 using (StreamReader sr = new StreamReader(Resp.GetResponseStream(), code)) 14 { 16 string str1 = sr.ReadToEnd();//获取得到的网址html返回数据,这里就可以使用某些解析html的dll直接使用了,比如htmlpaser 17 18 }
selenium 1 ChromeOptions options = new ChromeOptions(); 2 Proxy proxy = new Proxy(); 3 proxy.Kind = ProxyKind.Manual; 4 proxy.IsAutoDetect = false; 5 proxy.HttpProxy = 6 proxy.SslProxy = "125.31.19.26:80"; 7 options.Proxy = proxy; 8 options.AddArgument("ignore-certificate-errors"); 9 var chromedriver = new ChromeDriver(options); 10 chromedriver.Url = "http://www.whatismyip.com.tw/";
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论