// Ejemplo de como escribir una entidad a json private void writejson() { List <proxy> proxys = new List <proxy>(); proxy prox = new proxy(); prox.ip = "10.10.10.10"; prox.port = "10001"; proxys.Add(prox); proxy prox2 = new proxy(); prox2.ip = "10.10.10.10"; prox2.port = "10001"; proxys.Add(prox); string output = Newtonsoft.Json.JsonConvert.SerializeObject(proxys); string filePath = "proxylist.json"; using (System.IO.StreamWriter file = new System.IO.StreamWriter(System.IO.File.Create(filePath))) { file.WriteLine(output); } }
//抓去处理方法 static void getProxyList(object pageIndex) { string urlCombin = "http://www.xicidaili.com/wt/" + pageIndex.ToString(); string catchHtml = catchProxIpMethord(urlCombin, "UTF8"); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(catchHtml); HtmlNode table = doc.DocumentNode.SelectSingleNode("//div[@id='wrapper']//div[@id='body']/table[1]"); HtmlNodeCollection collectiontrs = table.SelectNodes("./tr"); for (int i = 0; i < collectiontrs.Count; i++) { HtmlAgilityPack.HtmlNode itemtr = collectiontrs[i]; HtmlNodeCollection collectiontds = itemtr.ChildNodes; //table中第一个是能用的代理标题,所以这里从第二行TR开始取值 if (i > 0) { HtmlNode itemtdip = (HtmlNode)collectiontds[3]; HtmlNode itemtdport = (HtmlNode)collectiontds[5]; HtmlNode itemtdspeed = (HtmlNode)collectiontds[13]; string ip = itemtdip.InnerText.Trim(); string port = itemtdport.InnerText.Trim(); string speed = itemtdspeed.InnerHtml; int beginIndex = speed.IndexOf(":", 0, speed.Length); int endIndex = speed.IndexOf("%", 0, speed.Length); int subSpeed = int.Parse(speed.Substring(beginIndex + 1, endIndex - beginIndex - 1)); //如果速度展示条的值大于90,表示这个代理速度快。 if (subSpeed > 90) { proxy temp = new proxy(ip, port, subSpeed); masterPorxyList.Add(temp); Console.WriteLine("当前是第:" + masterPorxyList.Count.ToString() + "个代理IP"); } } } }
public INativeHandleContract LoadAssembly(string assemblyname, string fullInterfaceName) { if (ad != null) { AppDomain.Unload(ad); } var domSetup = new AppDomainSetup(); domSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; domSetup.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory; domSetup.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; domSetup.LoaderOptimization = LoaderOptimization.MultiDomainHost; var adevidence = AppDomain.CurrentDomain.Evidence; ad = AppDomain.CreateDomain(assemblyname, adevidence, domSetup); ad.AssemblyResolve += ad_AssemblyResolve; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; remoteWorker = (proxy)ad.CreateInstanceAndUnwrap(typeof(proxy).Assembly.FullName, "INATO.UPINAIS.UCLibrary.proxy"); return(remoteWorker.GetControl(assemblyname, fullInterfaceName)); }
var request = new OutgoingRequestFrame(proxy, operation, idempotent, compress, context);
new OperaDriverCreator(proxy, timeout),
new WinAppDriverCreator(proxy, timeout),
new InternetExplorerDriverCreator(proxy, timeout),
new IosDriverCreator(proxy, timeout),
new FireFoxDriverCreator(proxy, timeout),
new HeadlessFirefoxDriverCreator(proxy, timeout),
new HeadlessEdgeDriverCreator(proxy, timeout),
new EdgeDriverCreator(proxy, timeout),
new HeadlessChromeDriverCreator(proxy, timeout),
new ChromeDriverCreator(proxy, timeout),
new AndroidDriverCreator(proxy, timeout),