Esempio n. 1
0
        /// <summary>
        /// 결과 페이지를 분석합니다.
        /// ex: https://exhentai.org/
        /// ex: https://exhentai.org/?inline_set=dm_t
        /// ex: https://exhentai.org/?page=1
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        public static List <EHentaiResultArticle> ParseResultPageThumbnailView(string html)
        {
            var result = new List <EHentaiResultArticle>();

            var document = new HtmlDocument();

            document.LoadHtml(html);
            var nodes = document.DocumentNode.SelectNodes("//div[@class='itg']/div[@class='id1']");

            foreach (var node in nodes)
            {
                try
                {
                    var article = new EHentaiResultArticle();

                    article.URL = node.SelectSingleNode("./div[@class='id2']/a").GetAttributeValue("href", "");

                    try { article.Thumbnail = node.SelectSingleNode("./div[@class='id3']/a/img").GetAttributeValue("src", ""); } catch { }
                    article.Title = node.SelectSingleNode("./div[@class='id2']/a").InnerText;

                    article.Files = node.SelectSingleNode(".//div[@class='id42']").InnerText;
                    article.Type  = node.SelectSingleNode(".//div[@class='id41']").GetAttributeValue("title", "");

                    result.Add(article);
                }
                catch { }
            }

            return(result);
        }
        /// <summary>
        /// 결과 페이지를 분석합니다.
        /// ex: https://exhentai.org/?inline_set=dm_m
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        public static List <EHentaiResultArticle> ParseResultPageMinimalListView(string html)
        {
            var result = new List <EHentaiResultArticle>();

            var document = new HtmlDocument();

            document.LoadHtml(html);

            HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//table[@class='itg gltm']/tr");

            for (int i = 1; i < nodes.Count; i++)
            {
                var node = nodes[i];

                var article = new EHentaiResultArticle();

                article.Type      = node.SelectSingleNode("./td/div").InnerText.Trim().ToLower();
                article.Thumbnail = node.SelectSingleNode(".//img").GetAttributeValue("src", "");
                if (article.Thumbnail.StartsWith("data"))
                {
                    article.Thumbnail = node.SelectSingleNode(".//img").GetAttributeValue("data-src", "");
                }
                article.Published = node.SelectSingleNode("./td[2]/div[2]/div[2]/div[1]/div[2]").InnerText.Trim();
                article.Files     = node.SelectSingleNode("./td[2]/div[2]/div[2]/div[2]/div[2]").InnerText.Trim();

                article.URL      = node.SelectSingleNode("./td[4]/a").GetAttributeValue("href", "");
                article.Title    = node.SelectSingleNode("./td[4]/a/div").InnerText.Trim();
                article.Uploader = node.SelectSingleNode("./td[6]/div/a").InnerText.Trim();

                result.Add(article);
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 결과 페이지를 분석합니다.
        /// ex: https://exhentai.org/?inline_set=dm_e
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        public static List <EHentaiResultArticle> ParseResultPageExtendedListView(string html)
        {
            var result = new List <EHentaiResultArticle>();

            var document = new HtmlDocument();

            document.LoadHtml(html);
            var nodes = document.DocumentNode.SelectNodes("//table[@class='itg glte']/tbody");

            foreach (var node in nodes)
            {
                try
                {
                    var article = new EHentaiResultArticle();

                    article.URL = node.SelectSingleNode(".//a").GetAttributeValue("href", "");
                    try { article.Thumbnail = node.SelectSingleNode(".//img").GetAttributeValue("src", ""); } catch { }

                    var g13 = node.SelectSingleNode(".//div[@class='g13e']");

                    article.Type      = g13.SelectSingleNode("./div").InnerText.ToLower();
                    article.Published = g13.SelectSingleNode("./div[2]").InnerText;
                    article.Uploader  = g13.SelectSingleNode("./div[4]").InnerText;
                    article.Files     = g13.SelectSingleNode("./div[5]").InnerText;

                    var gref = node.SelectSingleNode("./td[2]/div/a/div");

                    article.Title = gref.SelectSingleNode("./div").InnerText;

                    var desc     = gref.SelectNodes("./div/table/tbody");
                    var desc_dic = new Dictionary <string, List <string> >();

                    foreach (var nn in desc)
                    {
                        var cont = nn.SelectSingleNode("./td").InnerText.Trim();
                        cont = cont.Remove(cont.Length - 1);

                        var cc = new List <string>();

                        foreach (var ccc in nn.SelectNodes("./td[2]"))
                        {
                            cc.Add(ccc.InnerText);
                        }

                        desc_dic.Add(cont, cc);
                    }

                    article.Descripts = desc_dic;

                    result.Add(article);
                }
                catch { }
            }

            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// 결과 페이지를 분석합니다.
        /// ex: https://exhentai.org/
        /// ex: https://exhentai.org/?inline_set=dm_l
        /// ex: https://exhentai.org/?page=1
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        public static List <EHentaiResultArticle> ParseResultPageListView(string html)
        {
            var result = new List <EHentaiResultArticle>();

            var document = new HtmlDocument();

            document.LoadHtml(html);
            var nodes = document.DocumentNode.SelectNodes("//table[@class='itg']/tr");

            if (nodes.Count > 1)
            {
                nodes.RemoveAt(0);
            }

            foreach (var node in nodes)
            {
                try
                {
                    var article = new EHentaiResultArticle();

                    article.URL = node.SelectSingleNode("./td[3]/div/div[@class='it5']/a").GetAttributeValue("href", "");

                    try { article.Thumbnail = node.SelectSingleNode("./td[3]/div/div[@class='it2']/img").GetAttributeValue("src", ""); } catch { }
                    article.Title = node.SelectSingleNode("./td[3]/div/div[@class='it5']/a").InnerText;

                    article.Uploader  = node.SelectSingleNode("./td[4]/div/a").GetAttributeValue("href", "");
                    article.Published = node.SelectSingleNode("./td[2]").InnerText;
                    article.Type      = node.SelectSingleNode("./td/a/img").GetAttributeValue("alt", "");

                    result.Add(article);
                }
                catch { }
            }

            return(result);
        }
        /// <summary>
        /// 결과 페이지를 분석합니다.
        /// ex: https://exhentai.org/?inline_set=dm_e
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        public static List <EHentaiResultArticle> ParseResultPageExtendedListView(string html)
        {
            var result = new List <EHentaiResultArticle>();

            var document = new HtmlDocument();

            document.LoadHtml(html);

            Queue <HtmlNode> nodes = new Queue <HtmlNode>();
            var fn = document.DocumentNode.SelectNodes("//table[@class='itg glte']/tr");

            fn.ToList().ForEach(x => nodes.Enqueue(x));

            while (nodes.Count != 0)
            {
                var node = nodes.Dequeue();
                try
                {
                    var article = new EHentaiResultArticle();

                    article.URL = node.SelectSingleNode(".//a").GetAttributeValue("href", "");
                    try { article.Thumbnail = node.SelectSingleNode(".//img").GetAttributeValue("src", ""); } catch { }

                    var g13 = node.SelectSingleNode("./td[2]/div/div");

                    article.Type      = g13.SelectSingleNode("./div").InnerText.ToLower();
                    article.Published = g13.SelectSingleNode("./div[2]").InnerText;
                    article.Uploader  = g13.SelectSingleNode("./div[4]").InnerText;
                    article.Files     = g13.SelectSingleNode("./div[5]").InnerText;

                    var gref = node.SelectSingleNode("./td[2]/div/a/div");

                    article.Title = gref.SelectSingleNode("./div").InnerText;

                    if (article.Title.Contains("느와카나"))
                    {
                        ;
                    }

                    try
                    {
                        var desc     = gref.SelectNodes("./div//tr");
                        var desc_dic = new Dictionary <string, List <string> >();

                        foreach (var nn in desc)
                        {
                            var cont = nn.SelectSingleNode("./td").InnerText.Trim();
                            cont = cont.Remove(cont.Length - 1);

                            var cc = new List <string>();

                            foreach (var ccc in nn.SelectNodes("./td[2]//div"))
                            {
                                cc.Add(ccc.InnerText);
                            }

                            desc_dic.Add(cont, cc);
                        }

                        article.Descripts = desc_dic;
                    }
                    catch { }
                    result.Add(article);

                    var next = node.SelectNodes("./tr");
                    if (next != null)
                    {
                        next.ToList().ForEach(x => nodes.Enqueue(x));
                    }
                }
                catch { }
            }

            return(result);
        }