public string GetPageAlbumImageSource(PageAlbumImageModel model) { HtmlNode node = __BuildDomFromUrl(model.ImageUrl); var imgNode = node.SelectSingleNode("//div[@class='ba']/div[@style='text-align:center;']/img"); return(WebUtility.HtmlDecode(imgNode.GetAttributeValue("src", ""))); }
public IEnumerable <PageAlbumImageModel> GetPageAlbumImages(string pageAlias, string albumId) { string albumUrl = string.Format("https://m.facebook.com/{0}/albums/{1}/", pageAlias, albumId); while (albumUrl != null) { // https://m.facebook.com/FHNChallengingTheImpossible/albums/568853546917720/ HtmlNode dom = __BuildDomFromUrl(albumUrl); HtmlNodeCollection thumbAreaImgs = dom.SelectNodes("//div[@id='thumbnail_area']/a"); if (thumbAreaImgs != null || thumbAreaImgs.Count > 0) { foreach (var thumbItem in thumbAreaImgs) { PageAlbumImageModel img = new PageAlbumImageModel(); img.ImageUrl = "https://m.facebook.com" + WebUtility.HtmlDecode(thumbItem.GetAttributeValue("href", string.Empty)); img.ThumbImageUrl = WebUtility.HtmlDecode(thumbItem.SelectSingleNode("img").GetAttributeValue("src", string.Empty)); yield return(img); } } // more item? HtmlNode moreItemAnchorNode = dom.SelectSingleNode("//div[@id='m_more_item']/a"); if (moreItemAnchorNode != null) { albumUrl = "https://m.facebook.com" + moreItemAnchorNode.GetAttributeValue("href", string.Empty); } else { albumUrl = null; // end process } } }