private bool TryToParseProxy(string proxyHtmlRow, out IWebProxy proxy) { proxy = null; var cq = CQ.Create(proxyHtmlRow); var portString = cq["tr td:nth-child(2)"].Text(); int port; if (!Int32.TryParse(portString, out port)) { return(false); } var encodedHostnameString = cq["tr td:nth-child(1)"].Text(); if (string.IsNullOrWhiteSpace(encodedHostnameString)) { return(false); } var hostname = DecodeProxyHostname(encodedHostnameString); if (string.IsNullOrWhiteSpace(hostname)) { return(false); } Uri proxyUri; if (!Uri.TryCreate($"http://{hostname}:{port}", UriKind.RelativeOrAbsolute, out proxyUri)) { return(false); } proxy = new WrappedProxy(proxyUri); return(true); }
private bool TryToParseProxy(string proxyHtmlRow, out IWebProxy proxy) { proxy = null; var cq = CQ.Create(proxyHtmlRow); var portString = cq["tr td:nth-child(2)"].Text(); int port; if (!Int32.TryParse(portString, out port)) { return false; } var encodedHostnameString = cq["tr td:nth-child(1)"].Text(); if (string.IsNullOrWhiteSpace(encodedHostnameString)) { return false; } var hostname = DecodeProxyHostname(encodedHostnameString); if (string.IsNullOrWhiteSpace(hostname)) { return false; } Uri proxyUri; if (!Uri.TryCreate($"http://{hostname}:{port}", UriKind.RelativeOrAbsolute, out proxyUri)) { return false; } proxy = new WrappedProxy(proxyUri); return true; }