Example #1
0
        private static ExFavoriteList FromHtml(string htmlSource, ExFavoriteSortingMode sortingMode)
        {
            if (htmlSource == null)
            {
                return(null);
            }

            var          l            = new ExFavoriteList();
            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.OptionFixNestedTags = true;
            htmlDocument.LoadHtml(htmlSource);


            HtmlNodeCollection galleryNodes;

            try
            {
                var tableNode = htmlDocument.DocumentNode.SelectSingleNode("//*[@class='itg glt']");
                galleryNodes = tableNode.SelectNodes("//tr[./td/@class='gl1e']");
                foreach (var node in galleryNodes)
                {
                    l.Add(ExGallery.GetGalleryListItemFromNode(node));
                }

                l.PageCount         = ReadPageCount(htmlDocument);
                l.CurrentPageNumber = ReadCurrentPageNumber(htmlDocument);
            }
            catch (Exception ex)
            {
            }

            return(l);
        }
Example #2
0
        public static ExGallery GetGalleryListItemFromNode(HtmlNode node)
        {
            var g = new ExGallery();

            g.Title     = WebUtility.HtmlDecode(node.SelectSingleNode(".//div[@class='id2']/a").InnerText);
            g.Link      = node.SelectSingleNode(".//div[@class='id2']/a").GetAttributeValue("href", null);
            g.FileCount = int.Parse(node.SelectSingleNode(".//div[@class='id42']").InnerText.Replace(" files", ""));
            g.Category  = node.SelectSingleNode(".//div[@class='id41']").GetAttributeValue("title", "");
            g.Thumb     = node.SelectSingleNode(".//div[@class='id3']//img").GetAttributeValue("src", null);
            g.Rating    = GetRatingFromStars(node);
            return(g);
        }
Example #3
0
        public static ExGallery GetGalleryListItemFromNode(HtmlNode node)
        {
            var g = new ExGallery();

            g.Title     = WebUtility.HtmlDecode(node.SelectSingleNode(".//div[@class='gl4e glname']/div/a").InnerText);
            g.Link      = node.SelectSingleNode(".//div[@class='gl4e glname']/div/a").GetAttributeValue("href", null);
            g.FileCount = int.Parse(node.SelectSingleNode(".//td[2]/div/div[1]/div[5]").InnerText.Replace(" pages", ""));
            g.Category  = node.SelectSingleNode(".//td[2]/div/div[1]/div[1]").InnerText;
            g.Thumb     = node.SelectSingleNode(".//td/div/a/img").GetAttributeValue("src", null);
            g.Rating    = GetRatingFromStars(node);
            g.Published = ReadPublished(node);
            return(g);
        }
Example #4
0
        private static ExGallery GetExGalleryFromHtml(string link, string htmlSource)
        {
            if (htmlSource == null)
            {
                return(null);
            }

            var l = new ExGallery()
            {
                Link = link
            };
            HtmlDocument htmlDocument = new HtmlDocument()
            {
                OptionFixNestedTags = true
            };

            htmlDocument.LoadHtml(htmlSource);
            try
            {
                HtmlNodeCollection imageNodes = htmlDocument.DocumentNode.SelectNodes("//div[@id='gdt']/div[@class!='c']");
                foreach (var node in imageNodes)
                {
                    l.Add(ExGallery.GetImageListItemFromNode(node));
                }
                l.Rating            = ReadRating(htmlDocument);
                l.Title             = ReadTitle(htmlDocument);
                l.JapaneseTitle     = ReadJapaneseTitle(htmlDocument);
                l.PageCount         = ReadPageCount(htmlDocument);
                l.CurrentPageNumber = ReadCurrentPageNumber(htmlDocument);
                l.FileCount         = ReadFileCount(htmlDocument);
                l.Tags        = ReadTags(htmlDocument);
                l.Language    = ReadLanguage(htmlDocument);
                l.IsFavorited = ReadIsFavorited(htmlDocument);
                l.Thumb       = ReadThumb(htmlDocument);

                HtmlNodeCollection commentNodes = htmlDocument.DocumentNode.SelectNodes("//div[@class='c1']");
                if (commentNodes != null)
                {
                    foreach (var node in commentNodes)
                    {
                        l.Comments.Add(ExComment.FromNode(node));
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(l);
        }