private void LoadHtmlTemplate()
        {
            this.document = new HtmlDocument();
            this.document.Load( Assembly.GetExecutingAssembly().GetManifestResourceStream(HtmlTemplate) );

            this.table = new HtmlNodeCollection(document.GetElementbyId(LogEventTableId));
        }
Пример #2
0
        public void GetBrand(WebParserModel md)
        {
            WebRequest wr = WebRequest.Create("http://www.komus.ru/product/"+md.Referense.Substring(5)+"/#features");
            wr.Proxy=null;
            var resp = wr.GetResponse();
            var result = "";
            using(StreamReader sr = new StreamReader(resp.GetResponseStream(),Encoding.UTF8)){
                result = sr.ReadToEnd();
            }

            HtmlDocument html = new HtmlDocument();
            html.LoadHtml(result);

            var outer = html.GetElementbyId("breadcrumb_js");
            var wrapper = outer.NextSibling.NextSibling.NextSibling.NextSibling;
            var bigImg = wrapper.ChildNodes.FindFirst("img").Attributes["src"].Value;
            var cat="";
            md.Title=wrapper.ChildNodes[3].ChildNodes.FindFirst("h1").InnerText.Trim(); // title
            md.ImageUrl = bigImg; // img url
            outer = html.GetElementbyId("tabs--content-item-features");
            var tableLinesCount = outer.ChildNodes.FindFirst("table").Elements("tr").Last().ChildNodes[3].InnerText.Trim();
            if (tableLinesCount == " ")
            {
                cat = outer.ChildNodes.FindFirst("table").Elements("tr").Last().PreviousSibling.PreviousSibling.ChildNodes[3].InnerHtml;
                md.Brand = Regex.Match(cat, @"\w+(?=(</span>))").Value;
            }
            else {
                cat = tableLinesCount;
                md.Brand = cat;
            }

            //ViewBag.outer = bigImg;
        }
    private string GetQuestionnaire(string summaryPageUrl, int iFederationId)
    {
        HtmlWeb hw = new HtmlWeb();

        summaryPageUrl = "~/enrollment/dallas/Step2_2.aspx";
        StringBuilder sbHtml     = new StringBuilder();
        StringBuilder sbQuestion = new StringBuilder();

        // We load the summary page html from CIPMS
        string       htmlPathFromCIPMS = Server.MapPath(summaryPageUrl).Replace("CIPRS", "CIPMS");
        HtmlDocument htmlDoc           = hw.Load(htmlPathFromCIPMS);
        HtmlNode     content           = htmlDoc.DocumentNode.ChildNodes[1];
        // string imagePath;
        string s = htmlDoc.GetElementbyId("Label5").OuterHtml;

        // string test = htmlDoc.GetElementbyId("Label5").InnerHtml; //by sandhya
        //test = htmlDoc.GetElementbyId("Label5").InnerText;
        sbQuestion.Append(s);
        s = htmlDoc.GetElementbyId("RadioBtnQ3").OuterHtml;
        sbQuestion.Append(s);
        sbQuestion.Append("<br>");
        sbQuestion.Append(htmlDoc.GetElementbyId("Label9").OuterHtml.ToString());
        sbQuestion.Append("<br>");
        sbQuestion.Append(htmlDoc.GetElementbyId("Label9").OuterHtml.ToString());

        sbQuestion.Replace("asp:label", "span").Replace("cssclass", "class").Replace("asp:panel", "div").Replace("<br>", "<br/>");
        if (summaryPageUrl.ToLower().Contains("NJY"))
        {
            sbHtml.Replace("width='100%'", "width='85%'");
        }

        return(sbQuestion.ToString());
    }
Пример #4
0
        // JS resources.maxStorage returns capacity
        public static ResourceCapacity GetResourceCapacity(HtmlAgilityPack.HtmlDocument htmlDoc, Classificator.ServerVersionEnum version)
        {
            string WarehouseCap = "";
            string GranaryCap   = "";

            switch (version)
            {
            case Classificator.ServerVersionEnum.T4_4:
                WarehouseCap = htmlDoc.GetElementbyId("stockBarWarehouse").InnerText;
                GranaryCap   = htmlDoc.GetElementbyId("stockBarGranary").InnerText;
                break;

            case Classificator.ServerVersionEnum.T4_5:
                var cap = htmlDoc.DocumentNode.Descendants("div").Where(x => x.HasClass("capacity")).ToList();

                WarehouseCap = cap[0].Descendants("div").FirstOrDefault(x => x.HasClass("value")).InnerText;
                GranaryCap   = cap[1].Descendants("div").FirstOrDefault(x => x.HasClass("value")).InnerText;
                break;
            }
            return(new ResourceCapacity()
            {
                WarehouseCapacity = Parser.RemoveNonNumeric(WarehouseCap),
                GranaryCapacity = Parser.RemoveNonNumeric(GranaryCap)
            });
        }
Пример #5
0
        private void CollectLinks()
        {
            Receive <HtmlDocument>(page => {
                var doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(page.Content);

                var titleNode   = doc.GetElementbyId("firstHeading");
                var parentTitle = titleNode.InnerText;

                var linkNodes = doc.GetElementbyId("bodyContent").SelectNodes("//a");

                var linkedArticles = new HashSet <string>();
                foreach (var node in linkNodes)
                {
                    if (!node.Attributes.Contains("href") || !node.Attributes.Contains("title"))
                    {
                        continue;
                    }

                    var href  = node.Attributes["href"].Value;
                    var title = node.Attributes["title"].Value;
                    if (_linkRegex.IsMatch(href) && !ArticleBlacklist.Contains(title))
                    {
                        linkedArticles.Add(title);
                    }
                }

                Context.Parent.Tell(new ArticleParseResult(parentTitle, linkedArticles));
            });
        }
        /// <returns>Dictionary mapping player id to transfer value in 100,000's</returns>
        public Dictionary<int,int> GetMyTeamTransferValues()
        {
            var htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(_transfersPageHtmlString);
            
            //var body = htmlDoc.GetElementbyId("ismTeamDisplayGraphical");
            //var ismPitch = body.SelectSingleNode("//div[@class='ismPitch']");
            //var players = ismPitch.SelectNodes("//div[@class='ismPlayerContainer']");

            var result = new Dictionary<int, int>();

            for (int i = 0; i < 15; i++)
            {
                string playerIdStr = htmlDoc.GetElementbyId(string.Format("id_pick_formset-{0}-element", i)).GetAttributeValue("value", "");
                int playerId = int.Parse(playerIdStr);

                string salePriceStr = htmlDoc.GetElementbyId(string.Format("id_pick_formset-{0}-selling_price", i)).GetAttributeValue("value", "");
                int salePrice = int.Parse(salePriceStr);

                result.Add(playerId, salePrice);
            }

            /*foreach (var player in players)
            {
                string playerIdStr = player.SelectSingleNode("//a[@class='ismViewProfile']").GetAttributeValue("href",""); // string in form "#<id>"
                int playerId = int.Parse(playerIdStr.TrimStart('#'));

                string salePriceStr = player.SelectSingleNode("//span[@class='ismPitchStat']").InnerText; // string in form "£<sell price>"
                decimal salePrice = decimal.Parse(salePriceStr.TrimStart('£'));

                result.Add(playerId, salePrice);
            }*/

            return result;
        }
Пример #7
0
        static bool Get_IDX_HASTC(string address, ref MarketData hastcIdx)
        {
            bool            retVal      = true;
            CultureInfo     dataCulture = common.language.GetCulture("en-US");
            HttpWebRequest  wRequest    = HttpWebRequest.Create(new Uri(address)) as HttpWebRequest;
            HttpWebResponse wResponse   = wRequest.GetResponse() as HttpWebResponse;
            StreamReader    reader      = new StreamReader(wResponse.GetResponseStream());
            string          htmlContent = reader.ReadToEnd();

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(htmlContent);
            HtmlAgilityPack.HtmlNode nodeHNXIndex = doc.GetElementbyId("IDX");
            HtmlAgilityPack.HtmlNode nodeTongKL   = doc.GetElementbyId("QTY");
            if (nodeHNXIndex != null)
            {
                hastcIdx.Value = decimal.Parse(nodeHNXIndex.InnerHtml, dataCulture);
            }
            else
            {
                retVal = false;
            }
            if (nodeTongKL != null)
            {
                hastcIdx.TotalQty = decimal.Parse(nodeTongKL.InnerHtml, dataCulture);
            }
            else
            {
                retVal = false;
            }
            hastcIdx.TotalAmt = 0;
            return(retVal);
        }
Пример #8
0
        private HtmlNode handleTitleText(HtmlAgilityPack.HtmlDocument doc)
        {
            HtmlNode titleTable = null;

            for (int i = 0; i < title_text.Length; i++)
            {
                if (doc.GetElementbyId(title_text[i]) != null)
                {
                    titleTable = doc.GetElementbyId(title_text[i]).ParentNode;
                    while (titleTable.Name != "table")
                    {
                        titleTable = titleTable.NextSibling;
                    }
                    break;
                }
            }

            if (titleTable == null)
            {
                FindPage fp = new FindPage(url);
                fp.StartPosition = FormStartPosition.CenterParent;
                fp.Owner         = this;
                if (fp.ShowDialog() == DialogResult.OK)
                {
                    titleTable     = fp.titleNode;
                    animeName.Text = fp.title;
                }
            }

            return(titleTable);
        }
Пример #9
0
        public void DefineTheHtml_File(string filePath)
        {
            using (StreamReader reader = new StreamReader(filePath, Encoding.Default)) //Unicode-, ASCII-, UTF8-,UTF7-,UTF32-,BigEndianUnicode-
            {
                var html = new HtmlDocument();
                var stringHtml = reader.ReadToEnd();
                html.LoadHtml(stringHtml);

                var doc = html.GetElementbyId("initial_list"); //results <- поиск

                if (doc == null) // if true ? html from search list : html from my audio list
                {
                    doc = html.GetElementbyId("results");
                    var arr = doc.ChildNodes.Where(x => x.Name == "div").ToArray();
                    CreateCollectionFromSearch(arr);
                }

                if (doc == null)
                    throw new Exception("Не поддерживаемый html");

                var arrayHtmlNode = doc.ChildNodes.Where(x => x.InnerHtml != "").ToArray();

                CreateCollectionSongsMyAudio(arrayHtmlNode);
            }
        }
Пример #10
0
        public override async Task ExecuteAsync(Update update, Dictionary<string, string> parsedMessage)
        {
            var response = await GetHtml();
            string responseString;
            using (var tr = new StreamReader(response))
            {
                responseString = tr.ReadToEnd();
            }

            var startIndex = responseString.IndexOf("+=") + 2;
            var endIndex = responseString.IndexOf(";\ndocument");
            var tempStr = responseString.Substring(startIndex, endIndex - startIndex);
            var partsList = tempStr.Split('+').Select(x => x.Trim()).ToList();
            tempStr = "";
            // remove ' symbols
            partsList.ForEach(x => tempStr += x.Substring(1, x.Length - 2));

            HtmlDocument document = new HtmlDocument();
            document.LoadHtml(tempStr);
            var quote = document.GetElementbyId(QuoteTagId);
            var rating = document.GetElementbyId(RatingTagId);
            
            var result = rating.InnerText + Environment.NewLine + quote.InnerHtml.Replace(QuoteLineBreak, Environment.NewLine);
            
            await Bot.SendTextMessageAsync(update.Message.Chat.Id, HttpUtility.HtmlDecode(result), false, false, update.Message.MessageId);
        }
Пример #11
0
        public IEnumerable<IStockBonus> GetStockBonus(string stockCode)
        {
            string url = string.Format(@"http://vip.stock.finance.sina.com.cn/corp/go.php/vISSUE_ShareBonus/stockid/{0}.phtml", stockCode);

            string pageHtml = PageReader.GetPageSource(url);
            if (string.IsNullOrEmpty(pageHtml))
                return null;

            var htmlDocument = new HtmlDocument();
            htmlDocument.LoadHtml(pageHtml);

            HtmlNode titleNode = htmlDocument.DocumentNode.SelectSingleNode("//title");
            //string name = titleNode.InnerText.Substring(0, titleNode.InnerText.IndexOf("("));

            HtmlNode nodeSharebonus_1 = htmlDocument.GetElementbyId("sharebonus_1");
            HtmlNode nodeSharebonus_2 = htmlDocument.GetElementbyId("sharebonus_2");

            List<IStockBonus> lstStockBonus = new List<IStockBonus>();

            var lstNodes1 = nodeSharebonus_1.SelectNodes("tbody/tr");
            foreach (var item in lstNodes1)
            {
                var nodes = item.SelectNodes("td");
                string urlDetails = string.Format(@"http://vip.stock.finance.sina.com.cn/{0}", item.SelectSingleNode("td/a").Attributes["href"].Value);
                var stockBonus = new StockBonus()
                {
                    //Code = stockCode,
                    //ShortName = name,
                    DateOfDeclaration = DateTime.Parse(nodes[0].InnerText),// 公告日期
                    Type = BounsType.ProfitSharing,// 分红类型
                    ExdividendDate = DateTime.Parse(nodes[5].InnerText),// 除权除息日
                    RegisterDate = DateTime.Parse(nodes[6].InnerText), // 股权登记日
                };

                StockBonusDetailsParser(urlDetails, ref stockBonus);
                lstStockBonus.Add(stockBonus);
            }

            var lstNodes2 = nodeSharebonus_2.SelectNodes("tbody/tr");
            foreach (var item in lstNodes2)
            {
                var nodes = item.SelectNodes("td");
                string urlDetails = string.Format(@"http://vip.stock.finance.sina.com.cn/{0}", item.SelectSingleNode("td/a").Attributes["href"].Value);
                var stockBonus = new StockBonus()
                {
                    //Code = stockCode,
                    //ShortName = name,
                    DateOfDeclaration = DateTime.Parse(nodes[0].InnerText),// 公告日期
                    Type = BounsType.StockOption,// 配股类型
                    ExdividendDate = DateTime.Parse(nodes[4].InnerText),// 除权除息日
                    RegisterDate = DateTime.Parse(nodes[5].InnerText), // 股权登记日
                };

                StockBonusDetailsParser(urlDetails, ref stockBonus);
                lstStockBonus.Add(stockBonus);
            }

            return lstStockBonus;
        }
Пример #12
0
        private void DoSingleContent(string url)
        {
            //  url = "http://xidong.net/File001/File_8766.html";
            string content = fh.GetWebContents(url, Encoding.UTF8);
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(content);
            HtmlNode root = doc.DocumentNode;
            string title = doc.GetElementbyId("xdintrobg").SelectSingleNode("h1").InnerText;
            Console.WriteLine(title);
            string contMain = Helper.String.StringHelper.SubStr(content, "<script type=\"text/javascript\" src=\"http://src.xidong.net/js/select.js\"></script>",
                "<div id=\"ggad-content-bottom\">"
                );
            contMain = contMain.Replace("<!-- google_ad_section_start -->", "");
            contMain = contMain.Replace("<!-- google_ad_section_end -->", "");
            Regex reg = new Regex("(?i)(?s)<script.*?</script>");
            contMain = reg.Replace(contMain, "");
             Console.WriteLine(contMain);

            string links = "";
            Dictionary<string, string> linkList = new Dictionary<string, string>();
            HtmlNode node = doc.GetElementbyId("emulelink");
            for (int i = 1; i <= 50; i++)
            {
                node = doc.GetElementbyId("emulelink");
                node = node.SelectSingleNode("table[1]/tr[" + i + "]");
                if (node != null)
                {
                    if (node.InnerText.IndexOf("用迅雷、eMule等软件下载") > -1) continue;
                    HtmlNode hn1 = node.SelectSingleNode("td[1]/a[1]");
                    if (hn1 != null)
                    {
                        string rs = "";
                        string href = hn1.Attributes["href"].Value;
                        string text = hn1.InnerText;
                        string size = "0";
                        rs += text + "$$";
                        HtmlNode hn2 = node.SelectSingleNode("td[2]");
                        if (hn2 != null)
                        {
                            size = hn2.InnerText;
                        }
                        rs += size + "$$";
                        rs += href;

                        Console.WriteLine(rs);
                    }
                }
            }

            //  Console.WriteLine(content);
        }
Пример #13
0
        public Image Parse(HtmlDocument d, string url)
        {
            doc = d;
            HtmlNode podright = doc.GetElementbyId("pod_right");

            foreach (HtmlNode childNode in podright.ChildNodes)
            {
                if (childNode.GetAttributeValue("class", string.Empty) == "publication_time")
                {
                    string dateText = childNode.InnerText;
                    DateTime date = DateTime.Parse(dateText);
                    image.Date = date.Date;
                }
            }

            HtmlNode head = doc.GetElementbyId("page_head");

            foreach (HtmlNode childNode in head.ChildNodes)
            {
                if (childNode.Name == "h1")
                {
                    string title = childNode.InnerText;
                    image.Title = title;
                }
            }

            GetDownloadLink();

            HtmlNode primary =
                doc.DocumentNode.Descendants().First(
                    x => x.GetAttributeValue("class", string.Empty) == "primary_photo" && x.Name == "div");

            HtmlNode prevLink = primary.ChildNodes.First(x => x.Name == "a");

            string prevLinkRef = prevLink.GetAttributeValue("href", string.Empty);

            image.PreviousDayUrl = "http://photography.nationalgeographic.com" + prevLinkRef;

            HtmlNode potdImage = prevLink.ChildNodes.First(x => x.Name == "img");

            image.Description = potdImage.GetAttributeValue("alt", string.Empty);

            image.Url = potdImage.GetAttributeValue("src", string.Empty);

            GetPhotographer();

            return image;
        }
Пример #14
0
        private static Dictionary <string, EmailRecord> getNameValueByElementType(
            HtmlAgilityPack.HtmlDocument source,
            SalesForce salesForce
            )
        {
            Dictionary <string, EmailRecord> output
                = new Dictionary <string, EmailRecord>();

            var document = source.DocumentNode;

            foreach (KeyValuePair <string, bool> emailItem
                     in salesForce.emailHeaderIdentities)
            {
                if (emailItem.Value)
                {
                    HtmlAgilityPack.HtmlNode editNode = source.GetElementbyId(emailItem.Key);

                    if (editNode.Attributes.ToList().Count(x => x.Name == "value") >= 1)
                    {
                        HtmlAgilityPack.HtmlAttribute attribute = editNode.Attributes["value"];

                        EmailRecord record = new EmailRecord();

                        record.emailAddress = attribute.Value;

                        output.Add(emailItem.Key, record);
                    }
                }
            }

            return(output);
        }
        public OtoMotoResultPage(string rawResponse)
        {
            // TODO: Complete member initialization
            this.rawResponse = rawResponse;
            HtmlDocument htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(rawResponse);
            htmlDoc.OptionFixNestedTags = true;
            HtmlNode node = htmlDoc.GetElementbyId("mainRightOM");
            Console.WriteLine(node.InnerHtml);
            if (htmlDoc.ParseErrors != null)
            {
                // Handle any parse errors as required
                Console.WriteLine("Errors ;(");
            }
            else
            {
                Console.WriteLine("No errors, hurray!");
            }

            HtmlNode n = node.SelectSingleNode("div[@id='programList']");

            BuildCarList();
            //BuildLinkList();
            //BuildNextLink();
            //BuildPreviousLink();
        }
Пример #16
0
        private void AtualizarButton_Click(object sender, EventArgs e)
        {
            var    wc     = new WebClient();
            string pagina = wc.DownloadString("https://social.msdn.microsoft.com/Forums/pt-BR/home?filter=alltypes&sort=firstpostdesc");

            var htmlDocument = new HtmlAgilityPack.HtmlDocument();

            htmlDocument.LoadHtml(pagina);

            dataGridView1.Rows.Clear();

            string id       = string.Empty;
            string titulo   = string.Empty;
            string postagem = string.Empty;
            string exibicao = string.Empty;
            string resposta = string.Empty;
            string link     = string.Empty;

            foreach (HtmlNode node in htmlDocument.GetElementbyId("threadList").ChildNodes)
            {
                if (node.Attributes.Count > 0)
                {
                    id       = node.Attributes["data-threadid"].Value;
                    link     = "https://social.msdn.microsoft.com/Forums/pt-BR/" + id;
                    titulo   = WebUtility.HtmlDecode(node.Descendants().First(x => x.Id.Equals("threadTitle_" + id)).InnerText);
                    postagem = WebUtility.HtmlDecode(node.Descendants().First(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Equals("lastpost")).InnerText.Replace("\n", "").Replace("  ", ""));
                    exibicao = WebUtility.HtmlDecode(node.Descendants().First(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Equals("viewcount")).InnerText);
                    resposta = WebUtility.HtmlDecode(node.Descendants().First(x => x.Attributes["class"] != null && x.Attributes["class"].Value.Equals("replycount")).InnerText);
                }
                if (!string.IsNullOrEmpty(titulo))
                {
                    dataGridView1.Rows.Add(titulo, postagem, exibicao, resposta, link);
                }
            }
        }
Пример #17
0
 /// <summary>
 /// 分析json
 /// </summary>
 public void  analyse()
 {
     if (GetHtml())
     {
         try
         {
             Stopwatch watch = new Stopwatch();
             watch.Start();
             HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
             doc.LoadHtml(html);
             HtmlNode      node          = doc.GetElementbyId("data");
             StringBuilder stringbuilder = new StringBuilder(node.GetAttributeValue("data-state", ""));
             stringbuilder.Replace("&quot;", "'");
             stringbuilder.Replace("&lt;", "<");
             stringbuilder.Replace("&gt;", ">");
             GetUserInformation(stringbuilder.ToString());
             GetUserFlowerandNext(stringbuilder.ToString());
             watch.Stop();
             Console.WriteLine("分析Html用了{0}毫秒", watch.ElapsedMilliseconds.ToString());
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.ToString());
         }
     }
 }
        public static IEnumerable<KillStatistic> Parse(string htmlPage)
        {
            HtmlDocument page = new HtmlDocument();
            page.LoadHtml(htmlPage);

            var tables = page.GetElementbyId("killstatistics").Descendants("table");

            if (tables.Count() < 2) throw new ArgumentException("Page format not correct");

            var statsTable = tables.Last();
            var tableRows = statsTable.Descendants("tr").Skip(2);

            IList<KillStatistic> extractedStatistics = new List<KillStatistic>();
            foreach(var row in tableRows)
            {
                var columns = row.Descendants("td");

                KillStatistic stat = new KillStatistic { Monster = columns.First().InnerText.Replace("&#160;", ""), Date = DateTime.Now.AddDays(-1) };
                stat.KilledPlayers = Convert.ToInt32(columns.ElementAt(1).InnerText.Replace("&#160;", ""));
                stat.KilledByPlayers = Convert.ToInt32(columns.ElementAt(2).InnerText.Replace("&#160;", ""));

                extractedStatistics.Add(stat);
            }

            return extractedStatistics;
        }
Пример #19
0
        private string GetStringDataFormUrl(string url)
        {
            try
            {
                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
                myRequest.Method = "GET";
                WebResponse  myResponse = myRequest.GetResponse();
                StreamReader sr         = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);
                string       result     = sr.ReadToEnd();
                sr.Close();
                myResponse.Close();
                HtmlAgilityPack.HtmlDocument htmldoc = new HtmlAgilityPack.HtmlDocument();
                htmldoc.LoadHtml(result);
                HtmlAgilityPack.HtmlNode datanode = htmldoc.GetElementbyId("js-exportData");

                if (datanode != null)
                {
                    return(datanode.InnerText);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\n" + url);
            }
            return("");
        }
        public IEnumerable<Fixture> GetFixtures()
        {
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(ReadHtml());

            var calHolder = doc.GetElementbyId("CalendarHolder");

            var rows = calHolder.ChildNodes;

            foreach (var row in rows)
            {
                foreach (var column in row.ChildNodes)
                {
                    string currentHtml = column.InnerHtml;

                    while (currentHtml.Contains("a href"))
                                        {
                        yield return GetFixture(currentHtml);
                        int href = currentHtml.IndexOf("a href");
                        currentHtml = currentHtml.Substring(href + 1);
                    }
                }
            }

            yield break;
        }
Пример #21
0
        public static HtmlNode GetHTMLByID(string html, string id)
        {
            var doc = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(html);
            return(doc.GetElementbyId(id));
        }
Пример #22
0
 private static HtmlNode GetEmptyForm()
 {
     var htmlDoc = new HtmlDocument();
     htmlDoc.LoadHtml("<form id='f' action='/'></form>");
     var node = htmlDoc.GetElementbyId("f");
     return node;
 }
Пример #23
0
        public NewsModel GetNews(NewsModel news)
        {
            //html
            string htm = Html.GetHtml(news.SourceUrl, "http://uy.ts.cn");
            if (string.IsNullOrEmpty(htm)) return null;
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(htm);
            HtmlNode node = doc.GetElementbyId("content_value");
            if (node == null) return null;
            //图片
            //获取基URl
            //http://uy.ts.cn/news/node_900.htm
            //string url = string.Format("http://uy.ts.cn/{0}/node_{1}.htm", GetUrlBefore(Convert.ToInt32(news.Types.CatID)), news.Types.CatID);
            Html.EachImages(node, news.SourceUrl);
            //删除 注释
            IEnumerable<HtmlNode> commons = node.Elements("#comment");
            Remove:
            if (commons != null && commons.Count() > 0)
            {
                node.RemoveChild(commons.First());
                goto Remove;
            }

            news.Content = node.InnerHtml.Trim(' ','\r','\n');
            news.Time = DateTime.Now;
            news.Pic = _GetFirstImg(node);
            string innerText = node.InnerText;
            news.KeyWords = innerText.Length > 240 ? innerText.Substring(0, 240) : innerText;
            return news;
        }
Пример #24
0
        public static HeroInfo GetHeroInfo(HtmlAgilityPack.HtmlDocument htmlDoc)
        {
            var  values          = htmlDoc.DocumentNode.Descendants().Where(x => x.Attributes.Any(a => a.Value == "element current powervalue"));
            var  attributes      = htmlDoc.DocumentNode.Descendants().Where(x => x.Attributes.Any(a => a.Value == "element current powervalue tooltip"));
            var  lvl             = htmlDoc.DocumentNode.Descendants().Where(x => x.Attributes.Any(a => a.Value == "titleInHeader")).FirstOrDefault();
            var  resSelected     = htmlDoc.DocumentNode.Descendants().Where(x => x.Attributes.Any(a => a.Value == "resourcePick")).FirstOrDefault();
            byte resSelectedByte = 255;
            var  production      = htmlDoc.DocumentNode.Descendants().Where(x => x.Attributes.Any(a => a.Value == "production tooltip")).FirstOrDefault().ChildNodes[1].ChildNodes[3].InnerText;

            for (byte i = 0; i < 5; i++)
            {
                var selected = resSelected.ChildNodes[(i * 2) + 1].ChildNodes[1].ChildNodes[1].Attributes.Where(x => x.Value == "checked").FirstOrDefault();
                if (selected != null)
                {
                    resSelectedByte = i;
                }
            }

            //TODO: check hero items inventory and items on hero

            return(new HeroInfo()
            {
                Health = (int)Parser.ParseNum(values.ElementAt(0).ChildNodes[1].InnerText.Replace("%", "")),
                Experience = (int)Parser.ParseNum(values.ElementAt(1).ChildNodes[1].InnerText),
                LastChecked = DateTime.Now,
                FightingStrengthPoints = (int)Parser.ParseNum(attributes.ElementAt(0).ChildNodes[1].InnerText.Replace("%", "")),
                OffBonusPoints = (int)Parser.ParseNum(attributes.ElementAt(1).ChildNodes[1].InnerText.Replace("%", "")),
                DeffBonusPoints = (int)Parser.ParseNum(attributes.ElementAt(2).ChildNodes[1].InnerText.Replace("%", "")),
                ResourcesPoints = (int)Parser.ParseNum(attributes.ElementAt(3).ChildNodes[1].InnerText.Replace("%", "")),
                AvaliblePoints = (int)Parser.ParseNum(htmlDoc.GetElementbyId("availablePoints").InnerText.Split('/')[1]),
                Level = (int)Parser.ParseNum(lvl.InnerText.Split(' ').Last()),
                SelectedResource = resSelectedByte,
                HeroProduction = (int)Parser.ParseNum(production)
            });
        }
        public override List<DigimonType> GetDigimonTypes()
        {
            List<DigimonType> dTypes = new List<DigimonType>();

            string html = DownloadContent(STR_URL_MERC_SIZE_RANK_MAIN);
            HtmlDocument doc = new HtmlDocument();
            HtmlNode.ElementsFlags.Remove("option");
            doc.LoadHtml(html);

            HtmlNode selectTypes = doc.GetElementbyId("drpDigimon");
            foreach (HtmlNode type in selectTypes.ChildNodes) {
                if (!"option".Equals(type.Name)) {
                    continue;
                }
                DigimonType dType = new DigimonType() {
                    Code = Convert.ToInt32(type.Attributes["value"].Value),
                    Name = type.InnerText
                };
                dTypes.Add(dType);
                if (LogManager != null) {
                    LogManager.DebugFormat("Found {0}", dType);
                }
            }
            return dTypes;
        }
        public IDictionary<string, string> Parse(string html)
        {
            var doc = new HtmlDocument
            {
                OptionUseIdAttribute = true,
                OptionFixNestedTags = true
            };

            doc.LoadHtml(html);

            var fundamentals = new Dictionary<string, string>();

            foreach (var row in doc.GetElementbyId("currentValuationTable").Element("tbody").Elements("tr"))
            {
                if (row.Element("th") == null)
                    continue;

                var fundamental = HtmlEntity.DeEntitize(row.Element("th").InnerText);
                var value = HtmlEntity.DeEntitize(row.Elements("td").First().InnerText);

                Log.DebugFormat("Found: {0} = {1}", fundamental, value);
                fundamentals.Add(fundamental, value);
            }

            return fundamentals;
        }
Пример #27
0
        /// <summary>
        /// 从无忧代理网站得到当前最新的代理
        /// </summary>
        /// <param name="proxyUrl">代理Web URL</param>
        /// <param name="regionFilter">过滤指定的region,不过滤使用""或null</param>
        /// <returns>代理命令</returns>
        public static List <Proxy> _51proxied_HttpProxy(string proxyUrl, string regionFilter)
        {
            string resultString = new GetAndPostHelper().GETString(proxyUrl);

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(resultString);
            HtmlNode           divNode           = doc.GetElementbyId("tb");
            HtmlNodeCollection tdNodesCollection = divNode.SelectNodes("//div/table//td");
            List <HtmlNode>    tdNodes           = new List <HtmlNode>();

            foreach (HtmlNode node in tdNodesCollection)
            {
                tdNodes.Add(node);
            }
            List <Proxy> proxy = new List <Proxy>();

            for (int i = 0; i < tdNodes.Count / 4; i++)
            {
                string region = tdNodes[i * 4 + 3].InnerText.Trim();
                if (string.IsNullOrEmpty(regionFilter) || region == regionFilter)
                {
                    Proxy p = new Proxy();
                    p.IP     = tdNodes[i * 4 + 1].InnerText.Trim();;
                    p.Port   = int.Parse(tdNodes[i * 4 + 2].InnerText.Trim());
                    p.Region = region;
                    proxy.Add(p);
                }
            }
            return(proxy);
        }
Пример #28
0
        public List<Standing> GetGameBehind(string html)
        {
            var standing = new List<Standing>();
            try
            {
                #region 팀 순위 테이블 찾는다.
                var htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(html);
                var table = htmlDoc.GetElementbyId("xtable1");
                #endregion

                #region 승차 List<Standing> 에 값을 채운다.
                foreach (var xTr in table.SelectSingleNode("tbody").SelectNodes("tr"))
                {
                    var teamArr = xTr.SelectNodes("td").Select(e => e.InnerText).ToArray();
                    var teamInfo = new Standing();
                    if (!teamInfo.WriteInfo(teamArr)) return null;
                    standing.Add(teamInfo);
                }
                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.Log(ex);
            }

            return standing;
        }
Пример #29
0
        public string Compile(bool minify)
        {
            var js = jslastvalid;
            var html = htmllastvalid;

            // Merge fields
            var output = new StringBuilder(html);
            output.Replace("%resourcepath%", Program.BlobPathResource);
            output.Replace("%build%", Program.Config.Configuration.Build.ToString());
            output.Replace("%buildserial%", Program.Config.Configuration.BuildSerial.ToString());
            html = output.ToString();

            // Minify
            if (minify) {
                js = Minify.MinifyJS(js);
                html = Minify.MinifyHTML(html);
            }

            // Add JS
            var doc = new HtmlDocument();
            doc.LoadHtml(html);
            doc.GetElementbyId("_script_").AppendChild(doc.CreateComment(js));

            return doc.DocumentNode.OuterHtml;
        }
Пример #30
0
        private void WriteContent(HtmlDocument doc)
        {
            HtmlNode bodyContent = doc.GetElementbyId("bodyContent");

            var heading = doc.CreateElement("h1");
            heading.InnerHtml = "Heading";
            bodyContent.AppendChild(heading);

            HtmlNode table = bodyContent.CreateElement("table");
            table.CreateAttributeWithValue("class", "table table-striped table-bordered");
            var tableHead = table.CreateElement("thead");
            var headerRow = tableHead.CreateElement("tr");
            headerRow.CreateElementWithHtml("td", "First");
            headerRow.CreateElementWithHtml("td", "Second");
            headerRow.CreateElementWithHtml("td", "Third");
            headerRow.CreateElementWithHtml("td", "Fourth");
            headerRow.CreateElementWithHtml("td", "Fifth");

            HtmlNode tableBody = table.CreateElement("tbody");
            const string text = "Fi fa fo fum fi fa fo fum fi fa fo fum fi fa fo fum";
            for (int i = 0; i < 10; i++)
            {
                HtmlNode bodyRow = tableBody.CreateElement("tr");
                bodyRow.CreateElementWithHtml("td", i + " first " + text);
                bodyRow.CreateElementWithHtml("td", i + " second " + text);
                bodyRow.CreateElementWithHtml("td", i + " third " + text);
                bodyRow.CreateElementWithHtml("td", i + " fourth " + text);
                bodyRow.CreateElementWithHtml("td", i + " fifth " + text);
            }
        }
Пример #31
0
        public static ComicParseResult Parse(string html)
        {
            if (html == null)
                throw new ArgumentNullException(nameof(html));

            if (string.IsNullOrEmpty(html))
                throw new ArgumentException("html is empty", nameof(html));

            var doc = new HtmlDocument();
            doc.LoadHtml(html);

            var image = doc.GetElementbyId("main-comic");
            if (image == null)
            {
                return ComicParseResult.Fail("Could not find comic img element");
            }

            var dateNode = doc.QuerySelector(".past-week-comic-title");
            if (dateNode == null)
            {
                return ComicParseResult.Fail("Could not find date elemenet");
            }

            DateTime date;
            if (!DateTime.TryParseExact(dateNode.InnerText, "yyyy.MM.dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
            {
                return ComicParseResult.Fail($"Could not parse date: '{dateNode.InnerText}'");
            }

            var src = EnsureHttp(image.Attributes["src"].Value);

            return ComicParseResult.Succeed(src, date);
        }
Пример #32
0
 public List<MarketRateModel> GetMarketRate()
 {
     List<MarketRateModel> result = new List<MarketRateModel>();
     var html = Util.GetHtmlPage(ZHAOCAIBAO, System.Text.Encoding.GetEncoding("gb2312"));
     HtmlDocument doc = new HtmlDocument();
     doc.LoadHtml(html);
     var container = doc.GetElementbyId("container");
     if (container != null)
     {
         var notes = container.SelectNodes("div[@class='content-container']"+
             "/div[@class='main-content fn-clear']" +
             "/div[@class='zcb-product']" +
             "/div[@class='loan-product fn-clear']" +
             "/div[@class='several-months fn-clear']"
             );
         if (notes != null)
         {
             for (int i = 0; i < notes.Count(); ++i)
             {
                 result.Add(BuildMarketRate(notes[i]));
             }
         }
     }
     return result;
 }
Пример #33
0
        public static void RefreshLists()
        {
            WebClient    client     = new WebClient();
            string       stringPage = client.DownloadString("https://rankedboost.com/league-of-legends-wild-rift/items/");
            HtmlDocument doc        = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(stringPage);
            HtmlNodeCollection nodeList = doc.GetElementbyId("tierListTableWROneItems").ChildNodes;

            if (nodeList != null)
            {
                foreach (HtmlNode node in nodeList)
                {
                    var names = node.SelectNodes("//span[contains(@class, 'rune-name-lol-wr')]");
                    HtmlNodeCollection stats = doc.DocumentNode.SelectNodes("//div[@class='lolwr-champion-rank-table rune-td-lolwr-desc item-lol-wrlist']");

                    foreach (HtmlNode name in names)
                    {
                        nameList.Add(name.InnerText);
                    }
                    foreach (HtmlNode st in stats)
                    {
                        statsList.Add(st.InnerText);
                    }
                }
            }
        }
Пример #34
0
        static void Main()
        {
            Uri            targetUri  = new Uri("https://www.youtube.com/watch?v=sCw4LuINd5c");
            HttpWebRequest webRequest = HttpWebRequest.Create(targetUri) as HttpWebRequest;

            using (HttpWebResponse webResponse = webRequest.GetResponse() as HttpWebResponse)
            {
                using (Stream webResponseStream = webResponse.GetResponseStream())
                {
                    Encoding targetEncoding        = Encoding.UTF8;
                    HtmlAgilityPack.HtmlDocument s = new HtmlAgilityPack.HtmlDocument();
                    s.Load(webResponseStream, targetEncoding, true);
                    IXPathNavigable nav = s;

                    string title           = WebUtility.HtmlDecode(nav.CreateNavigator().SelectSingleNode("/ html / head / meta[@property =’og: title’] / @content").ToString());
                    string description     = WebUtility.HtmlDecode(nav.CreateNavigator().SelectSingleNode("/ html / head / meta[@property =’og: description’] / @content").ToString());
                    string fullDescription = WebUtility.HtmlDecode(s.GetElementbyId("eow - description").InnerHtml);

                    fullDescription = Regex.Replace(fullDescription, @"< (br | hr)[^>] >", Environment.NewLine);
                    fullDescription = Regex.Replace(fullDescription, @"<[^>] >", String.Empty).Trim();

                    Console.WriteLine(title);
                    Console.WriteLine(description);
                    Console.WriteLine(fullDescription);
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        public Dictionary<IClub,IEnumerable<string>> GetTeamNews()
        {
            var requester = new WebPageRequester(_logger);

            var url = _TEAMNEWS_PAGE;

            CookieContainer cookies = null;
            var response = requester.Get(url, ref cookies);

            var htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(response);
            var contentElement = htmlDoc.GetElementbyId("content");
            var leagueTableBody = contentElement.SelectSingleNode("//div[@class='ffs-team-news']/ol[@class='news']");

            var items = leagueTableBody.Elements("li"); // force evaluation

            var result = new Dictionary<IClub, IEnumerable<string>>();
            foreach(var item in items)
            {
                var clubName = item.SelectSingleNode("h2").InnerText;
                var players = ParseExpectedTeam(item);

                var club = Clubs.GetClubFromName(clubName);

                result.Add(club, players.ToArray());
            }

            return result;

        }
Пример #36
0
        /// <summary>
        /// 分析用户关注者列表
        /// </summary>
        /// <param name="followingContent"></param>
        public void AnalyseHTML(string htmlContent, Action getUserUrls, bool isGetUserInfo = false)
        {
            if (string.IsNullOrEmpty(htmlContent))
            {
                return;
            }

            try
            {
                Stopwatch watch = new Stopwatch();
                watch.Start();
                HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(htmlContent);

                HtmlNode      node          = doc.GetElementbyId("js-initialData");
                StringBuilder stringbuilder = new StringBuilder(node.InnerText);

                //ext: 获取用户个人信息
                if (isGetUserInfo)
                {
                    GetUserInformation(stringbuilder.ToString());
                }

                getUserUrls();

                watch.Stop();
                Console.WriteLine("分析用户{0}用了{1}毫秒", url_token, watch.ElapsedMilliseconds.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #37
0
        private bool GetCaptcha(string html, CookieCollection cookies, out Image captcha, out CookieCollection PostCookies, string szProxy)
        {
            string src;

            try
            {
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(html);
                HtmlNode a = doc.GetElementbyId("img_captcha");
                src = "http://www.ok.de" + a.Attributes["src"].Value;
            }
            catch (Exception e)
            {
                captcha     = null;
                PostCookies = null;
                return(false);
            }

            CookieCollection out_cooks;

            if (Http.HttpGetPictureRequest(src, out captcha, out out_cooks, cookies))
            {
                PostCookies = new CookieCollection();
                PostCookies.Add(cookies["PHPSESSID"]);
                PostCookies.Add(out_cooks["okrr"]);
                return(true);
            }

            PostCookies = null;
            return(false);
        }
        public IEnumerable<FileInfo> ParseHtmlForFiles(string html)
        {
            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            var manualDownloadsEl = doc.GetElementbyId("manual_downloads");

            if (manualDownloadsEl == null) yield break;

            IEnumerable<HtmlNode> lis =manualDownloadsEl.ChildNodes.Where(n => n.Name.Equals("li", StringComparison.OrdinalIgnoreCase));

            var idRegex = new Regex("\\d+$");

            foreach (HtmlNode li in lis)
            {
                HtmlNode descriptionNode = li.SelectNodes("descendant::h4").First();

                string description = string.Join("", descriptionNode.ChildNodes.Where(n => n.Name != "a").Select(n => n.InnerText).ToArray()).Replace("—", "").Trim();
                string date = li.SelectNodes("descendant::p/abbr").First().Attributes["title"].Value;
                string size = li.SelectNodes("descendant::p/strong").First().InnerText;
                string id = idRegex.Match(li.SelectNodes("a").First().Attributes["href"].Value).Value;

                HtmlNode anchor = li.SelectNodes("descendant::h4/a").First();

                string link = anchor.Attributes["href"].Value;
                string name = anchor.InnerText;

                yield return new FileInfo {Date = DateTime.Parse(date), Description = description, Id = id, Link = link, Name = name, Size = size};
            }
        }
Пример #39
0
            public static void GetFullInfo(HabraJob job)
            {
                HtmlAgilityPack.HtmlDocument html = new HtmlAgilityPack.HtmlDocument();
                // html.LoadHtml(wClient.DownloadString(job.Url));
                html.LoadHtml(GetHtmlString(job.Url));

                // так делать нельзя :-(
                var table = html.GetElementbyId("main-content").ChildNodes[1].ChildNodes[9].ChildNodes[1].ChildNodes[2].ChildNodes[1].ChildNodes[3].ChildNodes.Where(x => x.Name == "tr").ToArray();

                foreach (var tr in table)
                {
                    string category = tr.ChildNodes.FindFirst("th").InnerText;

                    switch (category)
                    {
                    case "Компания":
                        job.Company = tr.ChildNodes.FindFirst("td").FirstChild.InnerText;
                        break;

                    case "Образование:":
                        job.Education = HabraJob.ParseEducation(tr.ChildNodes.FindFirst("td").InnerText);
                        break;

                    case "Занятость:":
                        job.Employment = HabraJob.ParseEmployment(tr.ChildNodes.FindFirst("td").InnerText);
                        break;

                    default:
                        continue;
                    }
                }
            }
Пример #40
0
        public string InternalRFBGetCaptchaCNPJ()
        {
            try
            {
                var wc = new CookieAwareWebClient();
                wc.Headers["user-agent"] = UserAgent;
                var arrBytes = wc.DownloadData(AddressBase + AddressCaptchaCNPJ);
                var x = new HtmlDocument();
                x.LoadHtml(Encoding.UTF8.GetString(arrBytes));
                var image = x.GetElementbyId("imgcaptcha").GetAttributeValue("src", "");
                var viewstate = (string) null; // x.GetElementbyId("viewstate").GetAttributeValue("value", "");
                image = AddressBase + "/pessoajuridica/cnpj/cnpjreva/" + image.Replace("&amp;", "&");
                var bytes = wc.DownloadData(image);
                var filename = Guid.NewGuid() + ".jpg";
                var path = Server.MapPath("~\\temp\\" + filename);
                if (!Directory.Exists(Path.GetDirectoryName(path)))
                    Directory.CreateDirectory(Path.GetDirectoryName(path));

                System.IO.File.WriteAllBytes(path, bytes);
                Session["GetCNPJViewState"] = viewstate;
                Session["GetCNPJCookies"] = wc.CookieContainer;

                return VirtualPathUtility.ToAbsolute("~/temp/" + filename);
            }
            catch (Exception)
            {
                return null;
            }
        }
Пример #41
0
        private static async Task GenerateSampleData(int recordsNumber)
        {
            var httpClient = new HttpClient();
            var htmlResult = new HtmlDocument();
            var random = new Random();

            for (int i = 0; i < recordsNumber; i++)
            {                
                var htmlStringResult = await httpClient.GetStringAsync("http://randomtextgenerator.com/");
                
                htmlResult.LoadHtml(htmlStringResult);
                var randomText = htmlResult.GetElementbyId("generatedtext").InnerText;            

                var randomNumber = random.Next(150);
                var newModel = new SampleModel
                               {
                                   Id = Guid.NewGuid(),
                                   Description = randomText,
                                   CreatedDate = DateTime.Now.AddDays(randomNumber),
                                   ViewCount = randomNumber
                               };

                Db.SampleModels.Add(newModel);
                LuceneRepository<SampleModel>.AddUpdateLuceneIndex(newModel);
            }
            Db.SaveChanges();
        }
Пример #42
0
            public static void GetJobLinks(HtmlAgilityPack.HtmlDocument html)
            {
                try
                {
                    var trNodes = html.GetElementbyId("job-items").ChildNodes.Where(x => x.Name == "tr");

                    foreach (var item in trNodes)
                    {
                        var tdNodes = item.ChildNodes.Where(x => x.Name == "td").ToArray();
                        if (tdNodes.Count() != 0)
                        {
                            var location = tdNodes[2].ChildNodes.Where(x => x.Name == "a").ToArray();

                            jobList.Add(new HabraJob()
                            {
                                Url     = tdNodes[0].ChildNodes.First().Attributes["href"].Value,
                                Title   = tdNodes[0].FirstChild.InnerText,
                                Price   = tdNodes[1].FirstChild.InnerText,
                                Country = location[0].InnerText,
                                Region  = location[2].InnerText,
                                City    = location[2].InnerText
                            });
                        }
                    }
                }
                catch (Exception)
                {
                    return;
                }
            }
Пример #43
0
 private void moduleProperties_Click(object sender, EventArgs e)
 {
     HtmlAgilityPack.HtmlDocument doc  = HTMLDocumentConverter.mshtmlDocToAgilityPackDoc(htmlEditor1.HtmlDocument2);
     HtmlAgilityPack.HtmlNode     elem = doc.GetElementbyId(this.activeElement.id);
     CFormController.Instance.mainForm.propertiesForm.moduleChanged += new ModuleChanged(propertiesForm_moduleChanged);
     CFormController.Instance.mainForm.showProperties(elem);
 }
Пример #44
0
        private int GetPages(string URLAddress)
        {
            try
            {
                WebClient client = new WebClient();
                client.Encoding = System.Text.Encoding.GetEncoding("UTF-8");

                string html = client.DownloadString(URLAddress);
                HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

                htmlDoc.LoadHtml(html);
                HtmlNode Node1 = htmlDoc.GetElementbyId("pageBar");

                var nodecollection = Node1.SelectNodes("div[1]/a");
                if (nodecollection != null)
                {
                    return(nodecollection.Count);
                }
                else
                {
                    return(1);
                }
            }
            catch (Exception ex)
            {
                logger.Info("获取页数发生错误:" + ex.Message);
                logger.Info(URLAddress);
                return(0);
            }
        }
        public String GetBody(HtmlDocument doc)
        {
            var d = doc.GetElementbyId(containerId);

            //Remove nodes
            //d = RemoveNodes(d, SelectTags("script"));
            //d = RemoveNodes(d, SelectTags("div", "class", "rate"));
            //Header
            d = RemoveNodes(d, SelectTags("header"));
            //Similiar articles
            d = RemoveNodes(d, SelectTags("article", "class", "wnd_news_std"));

            //Remove preberite tudi
            String[] textToRemove = { "Preberite tudi:", "Preberite še:", "Prebertie še:" };
            d.Elements("h3").Where(x => textToRemove.Contains(x.InnerHtml)).ToList().ForEach(x =>
            {
                x.Remove();
            });

            StringBuilder sb = new StringBuilder();

            RecursiveSearch(d, sb);

            return sb.ToString();
        }
Пример #46
0
 public List<MarketRateModel> GetMarketRate()
 {
     List<MarketRateModel> result = new List<MarketRateModel>();
     var html = Util.GetHtmlPage(IFENG_URL, new UTF8Encoding());
     HtmlDocument doc = new HtmlDocument();
     doc.LoadHtml(html);
     var container = doc.GetElementbyId("photolist_28");
     if (container != null)
     {
         var nodes = container.SelectNodes("ul/li/a");
         if (nodes != null)
         {
             for (int i = 0; i < nodes.Count(); ++i)
             {
                 var r = BuildMarketRate(nodes[i]);
                 if (r != null)
                 {
                     result.Add(r);
                 }
             }
         }
     }
     else
     {
         throw new ApplicationException("Can not find elecment with id invest-projects");
     }
     return result;
 }
Пример #47
0
        private void CasAuthenticate(Site site, ref CookieCollection cookies, ref HtmlDocument document)
        {
            // read the parameters we need to know
            var form = document.GetElementbyId("fm1");
            var hidden = document.DocumentNode.Descendants("input").Where(a => a.Attributes["type"].Value == "hidden");

            var parameters = new StringBuilder();

            foreach (var p in hidden)
            {
                parameters.Append(string.Format("{0}={1}&", p.Attributes["name"].Value, p.Attributes["value"].Value));
            }

            var action = form.Attributes["action"];
            var username = ConfigurationSettings.AppSettings["username"];
            var password = ConfigurationSettings.AppSettings["password"];

            parameters.Append(string.Format("{0}={1}&", "username", username));
            parameters.Append(string.Format("{0}={1}", "password", password));

            // location to redirect back to the application
            var redirectLocation = string.Empty;
            MakeWebCallWithParameters("https://cas.ucdavis.edu:8443" + action.Value, parameters.ToString(), ref cookies, out redirectLocation);

            // get the ticket
            var ticketUrl = string.Format("https://cas.ucdavis.edu:8443/cas/login?service={0}", redirectLocation);
            var location = string.Empty;
            ErrorTypes errorType;
            MakeWebCall(ticketUrl, false, ref cookies, ref document, out location, out errorType);

            // get the aspx auth id
            var nothing = string.Empty;
            MakeWebCall(location, false, ref cookies, ref document, out nothing, out errorType);
        }
Пример #48
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String strResult;
            String randomKey = Request.QueryString["j_random_key"];

            if (randomKey != null && randomKey != "")
            {
                String strURl = LoginLink.validationLink + randomKey + "&flag=1";
                //String strURl = LoginLink.validationLink + randomKey;
                WebResponse objResponse;
                WebRequest  objRequest = HttpWebRequest.Create(strURl);
                objResponse = objRequest.GetResponse();
                using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                {
                    strResult = sr.ReadToEnd();
                    sr.Close();
                }
                HtmlWeb htmlWeb = new HtmlWeb();
                HtmlAgilityPack.HtmlDocument document = htmlWeb.Load(strURl);

                HtmlNode UserIdNode     = document.GetElementbyId("UserId");
                HtmlNode UserNameNode   = document.GetElementbyId("UserName");
                HtmlNode BranchIdNode   = document.GetElementbyId("branchID");
                HtmlNode BranchNameNode = document.GetElementbyId("BranchName");

                Session["USER_ID"]    = UserIdNode.InnerText.Trim();
                Session["UserName"]   = UserNameNode.InnerText.Trim();
                Session["BranchID"]   = BranchIdNode.InnerText.Trim();
                Session["BranchName"] = BranchNameNode.InnerText.Trim();
            }

            if (Session["BranchID"] != null)
            {
                if (Session["BranchID"].ToString().Equals("0001"))
                {
                    Response.Redirect("SpRequestDetails.aspx", true);
                }
                else
                {
                    Response.Redirect("BranchEntry.aspx", true);
                }
            }
            else
            {
                Response.Redirect(LoginLink.UltimasLogin, true);
            }
        }
Пример #49
0
        // GET: Pessoa
        public ActionResult Index()
        {
            //List<Pessoa> lista_de_Pessoas = new List<Pessoa>();
            List <Pessoa> lista_de_Estados = new List <Pessoa>();
            List <Pessoa> lista_de_Cidades = new List <Pessoa>();

            Iniciar();
            //baixar os dados do site que desejo obter as informações
            string pagina = _web.Get("gerador_de_pessoas");

            //criando uma instancia chamada documento_html
            var documento_html = new HtmlAgilityPack.HtmlDocument();

            //jogando os dados dentro do documento HTML
            documento_html.LoadHtml(pagina);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // coleção de dados genericos, no caso as idades do combo idade
            //validar esta perte, pois se nao tiver internet da erro
            HtmlNodeCollection nodeIdades = documento_html.GetElementById("idade").ChildNodes;

            List <string> lista_Idades = new List <string>();

            foreach (HtmlNode nodeIdade in nodeIdades)
            {
                if (nodeIdade.InnerText != "" && !nodeIdade.InnerText.Contains("\n"))
                {
                    lista_Idades.Add(nodeIdade.InnerText);
                }
            }
            ViewBag.Seleciona_Idade = new SelectList(lista_Idades);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // coleção de dados genericos, no caso os estados do combo estado
            HtmlNodeCollection nodeEstados = documento_html.GetElementbyId("cep_estado").ChildNodes;

            List <string> lista_Estados = new List <string>();

            //listar o nodeEstado e so add os itens se  for diferente de vazio e diferente da quebra de linha com estes espaços
            foreach (HtmlNode nodeEstado in nodeEstados)
            {
                if (nodeEstado.InnerText != "" && !nodeEstado.InnerText.Contains("\n"))
                {
                    //cmbEstadoPesquisa.Items.Add(nodeEstado.InnerText);
                    lista_Estados.Add(nodeEstado.InnerText);
                }
            }
            //ViewBag.mesmo nome que vai aparecer no HTML
            ViewBag.Estados = new SelectList(lista_Estados);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            var lista_cidades = new List <string>();

            lista_cidades.Add("Selecione");
            ViewBag.Cidades = new SelectList(lista_cidades);

            return(View());
        }
Пример #50
0
        public async Task <string> GetNTID()
        {
            LogStatus("Retrieving user's NTID...");

            WebRequest WReq = WebRequest.Create(_homeHeaderURL);

            WReq.Headers.Add(HttpRequestHeader.Cookie, _cookie);
            WReq.Credentials = CredentialCache.DefaultCredentials;

            LogStatus("----NTID WebRequest created.");

            WebResponse WResp = null;

            try
            {
                WResp = await WReq.GetResponseAsync();
            } catch (Exception e)
            {
                string error = e.Message;
                ShowError(error, MessageType.Error);
            }

            if (WResp == null)
            {
                return(null);
            }

            LogStatus("----NTID WebResponse received.");

            if (((HttpWebResponse)WResp).StatusCode == HttpStatusCode.OK)
            {
                string response;
                using (Stream dataStream = WResp.GetResponseStream())
                {
                    // Open the Stream using a StreamReader for easy access
                    StreamReader reader = new StreamReader(dataStream);

                    // Read the content
                    response = reader.ReadToEnd();
                }
                WResp.Close();

                // Parse the retrieved HTML for the user's NTID
                HtmlAgilityPack.HtmlDocument NTIDdoc = new HtmlAgilityPack.HtmlDocument();

                NTIDdoc.LoadHtml(response);

                HtmlNode node = NTIDdoc.GetElementbyId("myNTID");

                if (node == null)
                {
                    return(null);
                }

                return(node.GetAttributeValue("value", null));
            }

            return(null);
        }
        /// <returns>[Club => [Player Name => Player Return Date]]</returns>
        public Dictionary<IClub, Dictionary<string, DateTime>> GetInjuryNews()
        {
            var requester = new WebPageRequester(_logger);

            var url = _INJURYNEWS_PAGE;

            CookieContainer cookies = null;
            var response = requester.Get(url, ref cookies);

            var htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(response);

            var contentElement = htmlDoc.GetElementbyId("content");
            var injuriesTableBody = contentElement.SelectSingleNode("//table[@class='ffs-ib ffs-ib-full-content ffs-ib-sort']/tbody");

            var items = injuriesTableBody.Elements("tr"); // force evaluation

            var result = new Dictionary<IClub, Dictionary<string, DateTime>>();

            foreach (var item in items)
            {
                var clubName = item.SelectSingleNode(".//td[@class='team']").GetAttributeValue("title", null);
                if (clubName == null)
                    continue;

                var allCols = item.SelectNodes("td");
                if (allCols.Count < 4)
                    continue;

                var playerName = allCols[0].InnerText.Trim();
                if (playerName.Contains('('))
                    playerName = playerName.Split('(')[0].Trim();

                var returnDateStr = allCols[3].InnerText.Trim();
                DateTime returnDate;
                if (!DateTime.TryParseExact(returnDateStr, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out returnDate))
                    continue;


                var club = Clubs.GetClubFromName(clubName);

                Dictionary<string, DateTime> playerDict;
                if (!result.TryGetValue(club, out playerDict))
                {
                    playerDict = new Dictionary<string, DateTime>();
                    result.Add(club, playerDict);
                }

                if (playerDict.ContainsKey(playerName))
                    _logger.WriteErrorMessage(string.Format("Injury news already container entry for {0}({1})", playerName, clubName));
                else
                    playerDict.Add(playerName, returnDate);

                var i = 1;
            }

            return result;

        }
Пример #52
0
        private HtmlNode GetSection(string page)
        {
            //divListings
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(page);

            return(doc.GetElementbyId("divListings"));
        }
Пример #53
0
        public override string getComponentNumberFromLink(string link)
        {
            String[] part = link.Split('/');
            if (part.Length < 4)
            {
                return(null);
            }
            if (!part[2].Contains("digikey"))
            {
                return(null);
            }

            HtmlAgilityPack.HtmlDocument dom = DOMUtils.getDOMFromLink(link, "text/html");

            HtmlNode someNode = dom.GetElementbyId("reportPartNumber");

            if (someNode == null)
            {
                HtmlNode c1 = dom.GetElementbyId("product-overview");
                if (c1 == null)
                {
                    return(null);
                }
                HtmlNode c2 = DOMUtils.getNextChildNodeType(c1, "tbody", 0);
                if (c2 == null)
                {
                    c2 = c1;
                }
                HtmlNode c3 = DOMUtils.getNextChildNodeType(c2, "tr", 0);
                if (c3 == null)
                {
                    return(null);
                }
                HtmlNode c4 = DOMUtils.getNextChildNodeType(c3, "td", 0);
                if (c4 == null)
                {
                    return(null);
                }
                someNode = DOMUtils.getNextChildNodeType(c4, "meta", 0);
                if (someNode == null)
                {
                    return(null);
                }
            }
            return(someNode.InnerText.Trim(new char[] { '\r', '\t', '\n', ' ' }));
        }
        public JsonResult Consulta(string cep)
        {
            var sb = new StringBuilder();

            var buf = new byte[8192];

            Uri uri = new Uri("http://m.correios.com.br/movel/buscaCepConfirma.do?cepEntrada=" + cep +"&tipoCep=&cepTemp=&metodo=buscarCep");

            HttpWebRequest request = (HttpWebRequest)
             WebRequest.CreateDefault(uri);
            request.Method = "POST";

            HttpWebResponse response = (HttpWebResponse)
             request.GetResponse();

            Stream resStream = response.GetResponseStream();

            string tempString = null;
            int count = 0;

            do
            {
                count = resStream.Read(buf, 0, buf.Length);

                if (count != 0)
                {
                    tempString = Encoding.UTF8.GetString(buf, 0, count);
                    sb.Append(tempString);
                }
            }
            while (count > 0);

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(sb.ToString());

            var form = doc.GetElementbyId("frmCep");

            if (form == null)
                return Json(new { Mensagem = "Cep não encontrado!" }, JsonRequestBehavior.AllowGet);

            var elementos = form.SelectSingleNode("//div[@class='caixacampobranco']");

            var result = new List<string>();

            foreach (var item in elementos.SelectNodes("//span[@class='respostadestaque']"))
                result.Add(item.InnerText.Trim().Replace("\n", "").Replace("\t", "").Replace("  ", ""));

               return Json(new {
                Logradouro = result[0],
                Bairro = result[1],
                Localidade = new {
                    Cidade = result[2].Split('/')[0],
                    Estado = result[2].Split('/')[1]
                },
                Cep = result[3],
                Mensagem  = (result[3] != cep) ? "Cep Modificado" : "Sucesso"
            }, JsonRequestBehavior.AllowGet);
        }
Пример #55
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="url">标链接</param>
        /// <param name="ibnum">标号</param>
        /// <param name="lunchId">红包ID</param>
        /// <param name="amount">投资金额</param>
        private void InvestToRemote(string url, string retHTML, string ibnum, int lunchId, int amount)//红包ID,投资金额(根据红包来)
        {
            //html 解析值
            var userID  = ""; //用户ID; CUID
            var uniqKey = ""; //唯一key
            var _hash   = ""; //hash 值

            HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
            document.LoadHtml(retHTML);

            HtmlNode cuidNode = document.GetElementbyId("cuid");

            userID = cuidNode.Attributes["value"].Value;

            HtmlNode uniqKeyNode = document.GetElementbyId("uniqKey");

            uniqKey = uniqKeyNode.Attributes["value"].Value;

            HtmlNode _hashNode = document.GetElementbyId("J_form_msg2").SelectSingleNode("//input[@name='__hash__']");

            _hash = _hashNode.Attributes["value"].Value;

            //密码加密
            //var ppay = Encrypt(txtPayPWD.Text, uniqKey); //支付密码

            Thread.Sleep(3000);

            string utf8Str         = (string)webBrowser1.Document.InvokeScript("utf16to8", new string[] { txtPayPWD.Text });
            string xxteaEncryptStr = (string)webBrowser1.Document.InvokeScript("xxtea_encrypt", new string[] { utf8Str, uniqKey });
            string ppay            = (string)webBrowser1.Document.InvokeScript("encode64", new string[] { xxteaEncryptStr });

            //encode64(xxtea_encrypt(utf16to8(ppay), $("#uniqKey").val()))
            //txtLogs.AppendText("utf8Str:" + utf8Str);
            //txtLogs.AppendText("xxteaEncryptStr:" + xxteaEncryptStr);
            txtLogs.AppendText("ppay:" + ppay);

            string paramStr = string.Format("p_pay={0}&user_id={1}&ibnum={2}&lunchId={3}&amount={4}&__hash__={5}&vcode=", ppay, userID, ibnum, lunchId, amount, _hash);

            txtLogs.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + paramStr + "\r\n");

            var result     = WebHttpHeper.PostFormRequest(paramStr, url, PageURL_InvestCheckPPay, ref cookie);
            var resultText = JSON.DeserializeDynamic(result).ToString();

            txtLogs.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + resultText + "\r\n");
        }
Пример #56
0
        public string replaceHtml(string path, string brockName)
        {
            htmlDocument.Load(path);
            //HtmlNodeCollection collection = htmlDocument.DocumentNode.SelectSingleNode("div").ChildNodes;
            HtmlNode navNode = htmlDocument.GetElementbyId(brockName);

            strHtml.Append(navNode.InnerHtml);
            return(strHtml.ToString());
        }
Пример #57
0
        private string GetContent(string URLAddress, string code)
        {
            try
            {
                WebClient client = new WebClient();
                client.Encoding = System.Text.Encoding.GetEncoding("UTF-8");

                string html = client.DownloadString(URLAddress);
                HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();

                htmlDoc.LoadHtml(html);
                HtmlNode Node1    = htmlDoc.GetElementbyId("dadanTable");
                var      trnodes1 = Node1.SelectNodes("div[1]/div[1]/table[1]/tr");
                if (trnodes1 != null)
                {
                    Parallel.ForEach(trnodes1, item =>
                    {
                        var tdnodes = item.SelectNodes("td");    //所有的子节点
                        if (tdnodes[0].InnerText.Trim().Length > 0 && tdnodes[1].InnerText.Trim().Length > 0)
                        {
                            string sqlstring = string.Format(@"Insert into shishidadan(stock_code,trade_time,trade_price,trade_number,trade_amount,trade_type,record_date,record_time)values(
                                    '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", code, tdnodes[0].InnerText.Trim(), tdnodes[1].InnerText.Trim(), tdnodes[2].InnerText.Trim(), tdnodes[3].InnerText.Trim(), tdnodes[4].InnerText.Trim(),
                                                             DateTime.Today.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HH:mm:ss"));
                            Dbhelper.ExecuteNonQuery(Dbhelper.Conn, CommandType.Text, sqlstring);
                        }
                    });
                }
                var trnodes2 = Node1.SelectNodes("div[2]/div[1]/table[1]/tr");
                if (trnodes2 != null)
                {
                    Parallel.ForEach(trnodes2, item =>
                    {
                        var tdnodes = item.SelectNodes("td");    //所有的子节点
                        if (tdnodes[0].InnerText.Trim().Length > 0 && tdnodes[1].InnerText.Trim().Length > 0)
                        {
                            string sqlstring = string.Format(@"Insert into shishidadan(stock_code,trade_time,trade_price,trade_number,trade_amount,trade_type,record_date,record_time)values(
                                    '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", code, tdnodes[0].InnerText.Trim(), tdnodes[1].InnerText.Trim(), tdnodes[2].InnerText.Trim(), tdnodes[3].InnerText.Trim(), tdnodes[4].InnerText.Trim(),
                                                             DateTime.Today.ToString("yyyy-MM-dd"), DateTime.Now.ToString("HH:mm:ss"));
                            try
                            {
                                Dbhelper.ExecuteNonQuery(Dbhelper.Conn, CommandType.Text, sqlstring);
                            }
                            catch (Exception ex)
                            {
                                logger.Info(sqlstring);
                                throw new Exception(ex.Message);
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                logger.Info("Shishidadan," + URLAddress + "," + ex.Message);
            }
            return(string.Empty);
        }
Пример #58
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            if (searchName.Text.Length == 0)
            {
                return;
            }

            url = "https://zh.wikipedia.org/wiki/" + searchName.Text;

            try
            {
                HttpWebRequest  MyHttpWebRequest  = (HttpWebRequest)WebRequest.Create(url);
                HttpWebResponse MyHttpWebResponse = (HttpWebResponse)MyHttpWebRequest.GetResponse();
                Stream          MyStream          = MyHttpWebResponse.GetResponseStream();
                StreamReader    MyStreamReader    = new StreamReader(MyStream, Encoding.GetEncoding("UTF-8"));
                getdata = MyStreamReader.ReadToEnd();
                MyStreamReader.Close();
                MyStream.Close();
                //MessageBox.Show("OK");
            }
            catch
            {
                MessageBox.Show("獲得網站資料失敗");
            }

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(getdata);

            episode.Clear();
            cht_Title.Clear();
            listView1.Items.Clear();

            try
            {
                animeName.Text = doc.GetElementbyId("firstHeading").InnerText;
            }
            catch
            {
                animeName.Text = searchName.Text;
            }


            try
            {
                parseTable(normalizeTable(getTableString(getdata)));

                for (int i = 0; i < episode.Count; i++)
                {
                    listView1.Items.Add(episode.ElementAt(i));
                    listView1.Items[i].SubItems.Add(cht_Title.ElementAt(i));
                }
            }
            catch
            {
                MessageBox.Show("發生錯誤");
            }
        }
        /// <returns>The amount the logged on user has in the bank</returns>
        public decimal GetRemainingBudget()
        {
            var htmlDoc = new HtmlDocument();
            htmlDoc.LoadHtml(_transfersPageHtmlString);
            var ismToSpendElement = htmlDoc.GetElementbyId("ismToSpend");

            var remainingBudgetStr = ismToSpendElement.InnerText.TrimStart('£').Replace(',', '.');
            return decimal.Parse(remainingBudgetStr, System.Globalization.CultureInfo.InvariantCulture);
        }
Пример #60
0
        public static List <Building> GetResourcefields(HtmlAgilityPack.HtmlDocument htmlDoc, Classificator.ServerVersionEnum version)
        {
            switch (version)
            {
            case Classificator.ServerVersionEnum.T4_4:
                var             fields    = htmlDoc.GetElementbyId("village_map").Descendants("div").Where(x => !x.HasClass("labelLayer")).ToList();
                List <Building> resFields = new List <Building>();
                for (int i = 0; i < 18; i++)
                {
                    var vals     = fields.ElementAt(i).GetAttributeValue("class", "").Split(' ');
                    var building = new Building();

                    var aid = Convert.ToByte(vals.FirstOrDefault(x => x.StartsWith("aid")).Replace("aid", ""));
                    var lvl = Convert.ToByte(vals.FirstOrDefault(x => x.StartsWith("level") && x != "level").Replace("level", ""));
                    var gid = Convert.ToByte(vals.FirstOrDefault(x => x.StartsWith("gid")).Replace("gid", ""));
                    var uc  = vals.Contains("underConstruction");

                    building.Init(aid, lvl, gid, uc);
                    resFields.Add(building);
                }
                return(resFields);

            case Classificator.ServerVersionEnum.T4_5:
                var             fields5    = htmlDoc.GetElementbyId("resourceFieldContainer").ChildNodes.Where(x => x.Name == "div").ToList();
                List <Building> resFields5 = new List <Building>();
                for (int i = 0; i < 18; i++)
                {
                    var vals = fields5.ElementAt(i).GetClasses();     //.GetAttributeValue("class", "").Split(' ');
                    //fields5.ElementAt(1).GetClasses().
                    var building = new Building();

                    var aid = Convert.ToByte(vals.FirstOrDefault(x => x.StartsWith("buildingSlot")).Replace("buildingSlot", ""));
                    var lvl = Convert.ToByte(vals.FirstOrDefault(x => x.StartsWith("level") && x != "level").Replace("level", ""));
                    var gid = Convert.ToByte(vals.FirstOrDefault(x => x.StartsWith("gid")).Replace("gid", ""));
                    var uc  = vals.Contains("underConstruction");

                    building.Init(aid, lvl, gid, uc);
                    resFields5.Add(building);
                }
                return(resFields5);
            }
            return(null);
        }