public async Task<ForumPageMetadata> GetForumPageAsync(string forumID, int pagenumber = 1, FilterTagMetadata filter = null) { StringBuilder endpoint = new StringBuilder("forumdisplay.php?"); endpoint.AppendFormat("forumid={0}", forumID); endpoint.AppendFormat("&daysprune={0}", 15); endpoint.AppendFormat("&perpage={0}", 40); endpoint.AppendFormat("&posticon={0}", 0); endpoint.AppendFormat("&sortorder={0}", "desc"); endpoint.AppendFormat("&pagenumber={0}", pagenumber); var htmlDoc = await this.Client.GetHtmlAsync(endpoint.ToString()); return ForumParser.ParseForumPage(htmlDoc); }
private static void HandleFilters(ForumPageMetadata page, HtmlNode top) { var tagsListNode = top.Descendants("div") .Where(node => node.GetAttributeValue("class", "") .Equals("thread_tags")) .FirstOrDefault(); if (null != tagsListNode) { var filterNodes = tagsListNode.Descendants("a").ToList(); var filters = new List<FilterTagMetadata>(filterNodes.Count) { FilterTagMetadata.NoFilter }; page.Filters = filters; foreach (var filterNode in filterNodes) { string href = filterNode.GetAttributeValue("href", string.Empty); string title = filterNode.FirstChild.GetAttributeValue("title", string.Empty); string src = filterNode.FirstChild.GetAttributeValue("src", string.Empty); FilterTagMetadata filter = new FilterTagMetadata() { FilterUri = WebUtility.HtmlDecode(href), Title = WebUtility.HtmlDecode(title), TagUri = WebUtility.HtmlDecode(src) }; filters.Add(filter); } } }