protected void ExtractHotBoardEntries(HtmlNode rootNode) { IEnumerable<HtmlNode> linkNodes = rootNode.Descendants("a"); foreach (HtmlNode linkNode in linkNodes) { MitbbsBoardLinkMobile boardLink = new MitbbsBoardLinkMobile(); boardLink.ParentUrl = Url; if (boardLink.LoadFromHtml(linkNode)) { HotBoards.Add(MitbbsBoardLink.CreateFromMobileLink(boardLink)); } } }
public bool LoadFromHtml(HtmlNode rootNode, DataLoadedEventArgs loadedArgs) { bool isUserHomeLoaded = false; try { IEnumerable<HtmlNode> divNodes = rootNode.Descendants("div"); foreach (HtmlNode divNode in divNodes) { if (divNode.Attributes["id"].Value == "wenzhangyudu") { HtmlNodeCollection liNodes = divNode.ChildNodes[1].ChildNodes; for (int i = 0; i < liNodes.Count; i++) { HtmlNode liNode = liNodes[i]; if (liNode.Name == "li") { String bText = ""; IEnumerable<HtmlNode> bNodes = liNode.Descendants("b"); foreach (HtmlNode bNode in bNodes) { bText = HtmlUtilities.GetPlainHtmlText(bNode.FirstChild.InnerText); break; } IEnumerable<HtmlNode> linkNodes = liNode.Descendants("a"); foreach (HtmlNode linkNode in linkNodes) { String linkText = HtmlUtilities.GetPlainHtmlText(linkNode.FirstChild.InnerText); if (linkText == "站内邮箱") { MailboxUrl = linkNode.Attributes["href"].Value; isUserHomeLoaded = true; } else if(bText != "") { if (bText == "我的讨论区:") { MitbbsBoardLinkMobile boardLink = new MitbbsBoardLinkMobile(); boardLink.ParentUrl = Url; if (boardLink.LoadFromHtml(linkNode)) { MyBoards.Add(MitbbsBoardLink.CreateFromMobileLink(boardLink)); } } else if (bText == "我的最新文章:") { MitbbsSimpleTopicLinkMobile topicLink = new MitbbsSimpleTopicLinkMobile(); topicLink.ParentUrl = Url; if (topicLink.LoadFromHtml(linkNode)) { MyArticles.Add(MitbbsSimpleTopicLink.CreateFromMobileLink(topicLink)); } } } } } } } } } catch(Exception e) { loadedArgs.Error = e; } return isUserHomeLoaded; }