Esempio n. 1
0
        private IEnumerable <BaseArticleInfoModel> LoadCurrentPageLinks(HtmlDocument document)
        {
            var articleNodes = document.DocumentNode
                               .SelectSingleNode("//div[contains(@class, 'articles-list') and contains(@class, 'casual')]")
                               .ChildNodes
                               .Where(x => x.Name == "article");

            foreach (var item in articleNodes)
            {
                var title  = item.SelectSingleNode(".//div[@class='title']/a");
                var result = title.Attributes["href"].Value.GetRequestAndBaseAddress(_baseAddress);
                BaseArticleInfoModel article = new BaseArticleInfoModel
                {
                    Title                = title.InnerText,
                    BaseAddress          = result.Item2,
                    Address              = result.Item1,
                    PublishedDateTimeUtc =
                        DateTimeOffset
                        .ParseExact(
                            item.SelectSingleNode(".//div[@class='date']/time").Attributes["datetime"].Value,
                            "yyyy-MM-ddzHH:mm:ss", CultureInfo.InvariantCulture).UtcDateTime
                };
                yield return(article);
            }
        }
Esempio n. 2
0
        private ResponseArticleModel LoadSubDomainArticle(HtmlDocument document, BaseArticleInfoModel baseArticle)
        {
            ResponseArticleModel article = new ResponseArticleModel
            {
                Title = baseArticle.Title,
                PublishedDateTimeUtc = baseArticle.PublishedDateTimeUtc,
                Content = GenerateContent(document, "div", "p", "opennewstext", false)
            };

            return(article);
        }
Esempio n. 3
0
        private ResponseArticleModel LoadMainArticle(HtmlDocument document, BaseArticleInfoModel baseArticle)
        {
            ResponseArticleModel article = new ResponseArticleModel
            {
                Title = baseArticle.Title,
                PublishedDateTimeUtc = baseArticle.PublishedDateTimeUtc,
                ParseDateTime        = DateTime.UtcNow,
                Content = GenerateContent(document, "span", "p", "article-body")
            };

            return(article);
        }