internal static MarkInfo GetMarkInfo(HtmlDocument doc) { var nodes = doc.DocumentNode.Descendants().Where(noud => noud.GetAttributeValue("class", "NULL") == "znamkaInfo uprostred barevny"); if (nodes.Count() > 0) { MarkInfo markInfo = new MarkInfo(); HtmlNode mainNode = nodes.ElementAt(0).ParentNode; foreach (HtmlNode actualPropertyNode in mainNode.Descendants("div")) { if (actualPropertyNode.FirstChild.Name == "span") { String propertyName = actualPropertyNode.FirstChild.InnerText; switch (propertyName) { case "Předmět": markInfo.Subject = actualPropertyNode.LastChild.InnerText; break; case "Datum zkoušky": markInfo.Date = actualPropertyNode.LastChild.InnerText; break; case "Datum zadání hodnocení": markInfo.DateOfEnter = actualPropertyNode.LastChild.InnerText; break; case "Hodnocení": markInfo.Value = actualPropertyNode.LastChild.InnerText; break; case "Váha hodnocení": markInfo.MarkValuability = actualPropertyNode.LastChild.InnerText; break; case "Zadal": markInfo.Teacher = actualPropertyNode.LastChild.InnerText; break; case "Za co hodnocení": markInfo.ForWhat = actualPropertyNode.LastChild.InnerText; break; case "Okruh učiva": markInfo.TeachingOkruh = actualPropertyNode.LastChild.InnerText; break; case "Stručný komentář": markInfo.StructComment = actualPropertyNode.LastChild.InnerText; break; } } } return(markInfo); } return(null); }
public async Task <MarkInfo> GetMarkInfo(long ID) { if (_markInfoBuffer.ContainsKey(ID)) { return(_markInfoBuffer[ID]); } String response = await LoadRequest("https://www.iskola.cz/?cast=Hodnoceni&akce=znamka&id=" + ID.ToString()); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(response); MarkInfo loadedMarkInfo = DataParser.GetMarkInfo(doc); _markInfoBuffer.Add(ID, loadedMarkInfo); return(loadedMarkInfo); }