Beispiel #1
0
        public async Task LoadMarking()
        {
            String response = await LoadRequest("https://www.iskola.cz/?cast=Hodnoceni&akce=zak");

            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(response);
            _marksTable = DataParser.GetMarks(doc);
        }
Beispiel #2
0
        internal static MarksTable GetMarks(HtmlDocument doc)
        {
            IEnumerable <HtmlNode> nodes = doc.DocumentNode.Descendants().Where(node => node.Id == "vypis");

            if (nodes.Count() > 0)
            {
                HtmlNode   mainNode   = nodes.ElementAt(0).LastChild;
                MarksTable marksTable = new MarksTable();
                foreach (var node in mainNode.ChildNodes)
                {
                    RatedSubject newRatedSubject = new RatedSubject();
                    newRatedSubject.SubjectName   = node.FirstChild.InnerText;
                    newRatedSubject.Qualification = node.ChildNodes[2].InnerText;
                    newRatedSubject.Average       = node.LastChild.InnerText;
                    HtmlNode marksNode = node.ChildNodes[1];
                    foreach (HtmlNode actualMarkNode in marksNode.Descendants().Where(nd => nd.Name == "a"))
                    {
                        Mark newMark = new Mark();
                        newMark.Value = actualMarkNode.InnerText;
                        String idValue = actualMarkNode.GetAttributeValue("href", "NULL");
                        newMark.ID = Convert.ToInt64(idValue.Split(new String[] { ";id=" }, StringSplitOptions.None)[1]);
                        String   titleText  = actualMarkNode.GetAttributeValue("title", "NULL").Replace("&#10;", "");
                        String[] properties = titleText.Split(new String[] { "&#13;" }, StringSplitOptions.None);
                        foreach (String property in properties)
                        {
                            String[] splittedProperty = property.Split(':');
                            switch (splittedProperty[0].Trim())
                            {
                            case "Datum zkoušky": newMark.Date = splittedProperty[1].Trim(); break;

                            case "Zadal": newMark.Teacher = splittedProperty[1].Trim(); break;

                            case "Okruh učiva": newMark.TeachingOkruh = splittedProperty[1].Trim(); break;

                            case "Za co hodnocení": newMark.ForWhat = splittedProperty[1].Trim(); break;

                            case "Stručný komentář": newMark.StructComment = splittedProperty[1].Trim(); break;
                            }
                        }
                        newRatedSubject.Marks.Add(newMark);
                    }
                    marksTable.RatedSubjects.Add(newRatedSubject);
                }
                return(marksTable);
            }
            return(null);
        }