Example #1
0
        private static async Task <IList <FacebookPost> > ExtractTimelinePosts(Page page)
        {
            var document = new HtmlDocument();

            document.LoadHtml(await page.GetContentAsync());

            var nodes     = document.DocumentNode.QuerySelector("div[data-pagelet='ProfileTimeline']");
            var rootPosts = nodes.QuerySelectorAll("div[data-ad-comet-preview=message]").Select(x => x.ParentNode.ParentNode).ToList();

            var list = new List <FacebookPost>();

            foreach (var rootPost in rootPosts)
            {
                var fb = new FacebookPost
                {
                    Paragraphs = rootPost
                                 .QuerySelectorAll("div[data-ad-comet-preview=message] div.qzhwtbm6.knvmm38d div.cxmmr5t8.oygrvhab.hcukyx3x")
                                 .Select(x => WebUtility.HtmlDecode(x.InnerText))
                                 .ToList(),
                    Link = TransformLink(rootPost.QuerySelector("div.l9j0dhe7 a.oajrlxb2.g5ia77u1")?.GetAttributeValue("href", null))
                };

                list.Add(fb);
            }

            return(list);
        }
Example #2
0
 public bool IsSameWith(FacebookPost fbPost)
 {
     return(string.Join("", Paragraphs) == string.Join("", fbPost.Paragraphs));
 }