示例#1
0
        private void OneCountry(string url)
        {
            var html      = _webClient.DownloadString(url);
            var algorithm = html.Substring(html.IndexOf("eval", StringComparison.Ordinal),
                                           html.IndexOf("}))", StringComparison.Ordinal) + 3 - html.IndexOf("eval", StringComparison.Ordinal));
            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);
            var htmlNodes = htmlDocument
                            .DocumentNode.Descendants("tr")
                            .Where(node => node.GetAttributeValue("class", "")
                                   .Contains("spy1x")).ToArray();

            foreach (var htmlNode in htmlNodes)
            {
                var someText  = htmlNode.InnerText.Trim();
                var ipAddress = ParseHelper.DoRegexIp(someText);
                if (ipAddress == null)
                {
                    continue;
                }
                var portCrypt = htmlNode.InnerHtml.Substring(htmlNode.InnerHtml.IndexOf("\"+(", StringComparison.Ordinal) + 2,
                                                             htmlNode.InnerHtml.IndexOf("))<", StringComparison.Ordinal)
                                                             - htmlNode.InnerHtml.IndexOf("\"+(", StringComparison.Ordinal) - 1);
                var port = ParseHelper.DoWithOutJs(algorithm, portCrypt);
                //var port = ParseHelper.DoJs(algorithm, portCrypt);
                var row = _sheet.CreateRow(++_indexRow);
                row.CreateCell(0).SetCellValue(ipAddress + ':' + port);
                _sheet.AutoSizeColumn(0);
            }
        }