예제 #1
0
파일: Parse.cs 프로젝트: vrana/HlidacStatu
        private static List <_usneseni> VsechnaUsneseniVyboru(int vyborId)
        {
            Console.Write($"Vsechna usneseni vyboru {vyborId}");
            List <_usneseni> ret = new List <_usneseni>();
            int page             = 1;

            while (true)
            {
                Console.Write($" p{page}");
                string url = string.Format(_vyborUsneseni, vyborId + 5, page);
                var    xp  = GetPage(url);

                var xrows = xp.GetNodes("//div[@id='main-content']//table//tr");
                if (xrows == null)
                {
                    return(ret);
                }
                if (xrows.Count == 0)
                {
                    return(ret);
                }

                foreach (var xrow in xrows)
                {
                    _usneseni j    = new _usneseni();
                    var       jdoc = XPath.Tools.GetNode(xrow, "td[1]/a");
                    j.popis = XPath.Tools.GetNodeText(xrow, "td[3]")?.Trim() ?? "";
                    if (!string.IsNullOrEmpty(j.popis))
                    {
                        j.popis += ": ";
                    }
                    j.popis += XPath.Tools.GetNodeText(xrow, "td[2]");
                    var pageUrl = "https://www.psp.cz/sqw/" + jdoc.GetAttributeValue("href", "");
                    Console.Write(".");
                    UsneseniPage(pageUrl, ref j);
                    ret.Add(j);
                }



                page++;
            }

            //return ret;
        }
예제 #2
0
파일: Parse.cs 프로젝트: vrana/HlidacStatu
        private static void UsneseniPage(string url, ref _usneseni j)
        {
            var xp    = GetPage(url);
            var title = xp.GetNodeText("//div[@id='main-content']//div[@class='page-title']");
            var datum = GetRegexGroupValue(title, @"\((?<datum>\d{1,2}(\.)? \s* \w{4,15}\s*\d{4}) (\w|\s|,)*  \)", "datum");

            if (!string.IsNullOrEmpty(datum))
            {
                j.datum = DateTime.ParseExact(datum, new string[] { "d MMMM yyyy", "d. MMMM yyyy", "d. MMMMyyyy" }, System.Globalization.CultureInfo.GetCultureInfo("cs-CZ"), System.Globalization.DateTimeStyles.AssumeLocal); //19. února 2020
            }
            j.cislo = int.Parse(GetRegexGroupValue(title, @"č\. \s* (?<cislo>\d*) \s*", "cislo"));

            var files = xp.GetNodes("//div[@id='main-content']//div[@class='document-media-attachments-x']//ul//li");

            if (files != null && files.Count > 0)
            {
                j.fileUrl = "https://www.psp.cz/sqw/text/" + XPath.Tools.GetNodeAttributeValue(files[0], "a", "href");
            }
        }