Example #1
0
        public static List <RelatedCompany> Predecessors(string html)
        {
            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(html);

            var elements = doc.DocumentNode.SelectNodes("//div[@class='leftColumnGraph']");

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

            List <RelatedCompany> result = new List <RelatedCompany>();

            foreach (var element in elements)
            {
                RelatedCompany comp = new RelatedCompany();
                comp.Name = element.SelectSingleNode(".//*[@class='graph-line-link marR12']").InnerText.GetHTMLDecoded();
                comp.OGRN = element.SelectSingleNode(".//*[@class='ogrn-inn']").InnerText;
                result.Add(comp);
            }
            return(result);
        }
Example #2
0
        public static List <RelatedCompany> RelatedCompanies(string html)
        {
            HtmlDocument doc = new HtmlDocument();

            html = GlobalReplacements(html);
            doc.LoadHtml(html);

            var elements = doc.DocumentNode.SelectNodes("//div[@class='leftColumnGraph']");

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

            List <RelatedCompany> result = new List <RelatedCompany>();

            foreach (var element in elements)
            {
                RemoveElements(element, ".//span[@class='smallText lightGrey nowrap']");
                RemoveElements(element, ".//div[@class='peripheral textRight peripheral_lt480']");
                RemoveElements(element, ".//div[@class='stickOut stickOut__display1024 textRight leftNum']");
                RemoveElements(element, ".//*[contains(@class,'graphItemElement') and contains(.,'strikeThrough')]");
                RemoveElements(element, ".//*[contains(text(),'Подробнее')]");
                RemoveElements(element, ".//*[contains(text(),'Показать')]");

                RemoveElements(element, ".//a[@class='connectionsLink']");
                RemoveElements(element, ".//span[@class='percentUp']");
                RemoveElements(element, ".//span[@class='percentDown']");

                ChangeNodeName(element, ".//div[@class='inlineBlock floatRight ']", "span");
                ChangeNodeName(element, ".//div[@class='inlineBlock']", "span");

                RemoveP(element);

                var gitems = element.SelectNodes(".//*[contains(@class,'graphItemElement')]");
                if (gitems != null)
                {
                    foreach (var it in gitems)
                    {
                        if (it.InnerHtml.Contains("strikeThrough"))
                        {
                            it.Remove();
                        }
                    }
                }

                RelatedCompany company = new RelatedCompany();
                company.Name = element.ParentNode.InnerHtml.Replace("href", "attr").Replace("class=\"halfMargin mobile-stickOut graphItemElement\"", "style=\"margin-left:30px;margin-top:10px;\"");

                try
                {
                    var el = element.ParentNode.NextSibling.NextSibling;

                    ChangeNodeName(el, ".//div[@class='inlineBlock floatRight ']", "span");
                    ChangeNodeName(el, ".//div[@class='inlineBlock']", "span");

                    RemoveElements(el, ".//*[contains(text(),'интернете')]");
                    RemoveElements(el, ".//*[contains(text(),'Учрежденные')]");
                    RemoveElements(el, ".//*[contains(text(),'ТПП')]");
                    RemoveElements(el, ".//*[contains(text(),'Лицензии')]");
                    RemoveElements(el, ".//*[contains(text(),'Товарные')]");

                    RemoveElements(el, ".//span[@class='percentUp']");
                    RemoveElements(el, ".//span[@class='percentDown']");

                    company.Name += "" + el.InnerHtml.Replace("href", "attr");
                    company.Name  = company.Name.Replace("<span>", "<span class='silversmall'>").Replace("<span class=\"inlineBlock floatRight \"><span class=\"inlineBlock floatRight \">", "&nbsp;&nbsp;<span class=\"inlineBlock floatRight \"><span class=\"inlineBlock floatRight \">");
                }
                catch { }

                result.Add(company);
            }
            return(result);
        }