C# selenium 設置代理IP和常用參數設置


var cdSvc = ChromeDriverService.CreateDefaultService();
cdSvc.HideCommandPromptWindow = true;
//IWebDriver driver = new ChromeDriver(System.AppDomain.CurrentDomain.BaseDirectory.ToString());
var option = new ChromeOptions();
// option.AddArgument("--incognito"); // 影身模式
//option.AddArgument("headless");//設為無頭模式
option.AddArgument("disable-infobars");//去掉提示:Chrome正收到自動測試軟件的控制
option.AddArguments("--proxy-server=http://192.168.0.1:1123"); 

//這種設置無效 //option.AddArguments("--proxy-server=http://117.21.178.7:12150"); option.AddArguments("lang=zh_CN.UTF-8"); option.AddExcludedArgument("enable-automation"); option.AddAdditionalCapability("useAutomationExtension", false); //設置代理IP ip+port string ip =192.168.0.1:1123 Proxy proxy = new Proxy(); proxy.Kind = ProxyKind.Manual; proxy.IsAutoDetect = false; proxy.HttpProxy = ip; // proxy.HttpProxy =ip; //這里是http //proxy.SslProxy = ip; //這里是ssl option.Proxy = proxy; option.AddArgument("ignore-certificate-errors"); driver = new ChromeDriver(cdSvc, option);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM