public bool Execute() { try { Result = new ArticleScrape(Parameters).Execute(); return true; } catch(Exception e) { return false; } }
public ArticleResult ConvertToResult(string result) { HtmlDocument htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(result); var node = htmlDocument.DocumentNode; ArticleResult a = new ArticleResult() { Title = (node.Descendants("h1").FirstOrDefault()?.InnerText ?? string.Empty).Trim(), ViewsCount = (node.Descendants("p").FirstOrDefault(c => c.Attributes["class"]?.Value == "views-count")?.InnerText ?? string.Empty).Trim(), AuthorTime = (node.Descendants("p").FirstOrDefault(c => c.Attributes["class"]?.Value == "author-time")?.InnerText ?? string.Empty).Trim(), Content = (node.Descendants("div").FirstOrDefault(c => c.Attributes["class"]?.Value == "post-content")?.InnerHtml ?? string.Empty).Trim() }; a.Title = System.Net.WebUtility.HtmlDecode(a.Title); a.AuthorTime = a.AuthorTime.Replace("\n", string.Empty).RemoveDoubleSpaces(); return a; }
internal void InitializeNewArticle(ArticleResult article) { ArticleLoading = false; Articles.Clear(); Articles.Add(article); }