Exemple #1
0
        public async Task<FrontPageWebArticleEntity> GetFrontPageArticle(string url)
        {
            HtmlDocument articleDoc = (await _webManager.DownloadHtml(url)).Document;
            HtmlNode articleNode =
                articleDoc.DocumentNode.Descendants()
                    .FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("cavity left"));
            HtmlNode articleBodyNode =
                articleNode.Descendants()
                    .FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("organ article"));

            string html = await PathIO.ReadTextAsync("ms-appx:///Assets/MainSite.html");

            var doc2 = new HtmlDocument();

            doc2.LoadHtml(html);

            HtmlNode bodyNode = doc2.DocumentNode.Descendants("body").FirstOrDefault();

            bodyNode.InnerHtml = articleBodyNode.OuterHtml;

            var frontPageArticleEntity = new FrontPageWebArticleEntity();
            frontPageArticleEntity.MapTo(WebUtility.HtmlDecode(doc2.DocumentNode.OuterHtml), 1);
            return frontPageArticleEntity;
        }
Exemple #2
0
 public async Task<FrontPageWebArticleEntity> GetArticleMetaData(string url)
 {
     HtmlDocument articleDoc = (await _webManager.GetData(url)).Document;
     string articleHtml = await ParseArticleHtml(articleDoc);
     var frontPageArticleEntity = new FrontPageWebArticleEntity();
     frontPageArticleEntity.MapTo(WebUtility.HtmlDecode(articleHtml), 1);
     return frontPageArticleEntity;
 }