public async Task<List<ForumThreadEntity>> GetBookmarks(ForumEntity forumCategory) { var forumSubcategoryList = new List<ForumEntity>(); var forumThreadList = new List<ForumThreadEntity>(); String url = forumCategory.Location; if (forumCategory.CurrentPage > 0) { url = forumCategory.Location + string.Format(Constants.PAGE_NUMBER, forumCategory.CurrentPage); } HtmlDocument doc = (await _webManager.DownloadHtml(url)).Document; HtmlNode forumNode = doc.DocumentNode.Descendants().FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("threadlist")); foreach (HtmlNode threadNode in forumNode.Descendants("tr").Where(node => node.GetAttributeValue("class", string.Empty).StartsWith("thread"))) { var threadEntity = new ForumThreadEntity(); threadEntity.Parse(threadNode); forumThreadList.Add(threadEntity); } return forumThreadList; }
private ForumThreadEntity ParseEntity(string html) { var doc = new HtmlDocument(); doc.LoadHtml(html); var thread = new ForumThreadEntity(); thread.Parse( doc.DocumentNode.Descendants("tr") .First(node => node.GetAttributeValue("class", string.Empty).StartsWith("thread"))); return thread; }
public async Task<List<ForumThreadEntity>> GetForumThreads(ForumEntity forumCategory, int page) { // TODO: Remove parsing logic from managers. I don't think they have a place here... var url = forumCategory.Location + string.Format(Constants.PAGE_NUMBER, page); HtmlDocument doc = (await _webManager.DownloadHtml(url)).Document; HtmlNode forumNode = doc.DocumentNode.Descendants().FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("threadlist")); var forumThreadList = new List<ForumThreadEntity>(); foreach (HtmlNode threadNode in forumNode.Descendants("tr").Where(node => node.GetAttributeValue("class", string.Empty).StartsWith("thread"))) { var threadEntity = new ForumThreadEntity(); threadEntity.Parse(threadNode); forumThreadList.Add(threadEntity); } return forumThreadList; }
public async Task<ObservableCollection<ForumThreadEntity>> GetBookmarks(ForumEntity forumCategory, int page) { var forumThreadList = new ObservableCollection<ForumThreadEntity>(); String url = Constants.BOOKMARKS_URL; if (forumCategory.CurrentPage > 0) { url = Constants.BOOKMARKS_URL + string.Format(Constants.PAGE_NUMBER, page); } HtmlDocument doc = (await _webManager.GetData(url)).Document; HtmlNode forumNode = doc.DocumentNode.Descendants() .FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("threadlist")); foreach ( HtmlNode threadNode in forumNode.Descendants("tr") .Where(node => node.GetAttributeValue("class", string.Empty).StartsWith("thread"))) { var threadEntity = new ForumThreadEntity(); threadEntity.Parse(threadNode); threadEntity.IsBookmark = true; forumThreadList.Add(threadEntity); } return forumThreadList; }