Beispiel #1
0
        /// <summary>
        /// 갤러리 블록으로 썸네일 파싱
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        static public HitomiArticle ParseGallery2(string source)
        {
            HitomiArticle article = new HitomiArticle();

            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(source);
            HtmlNode nodes = document.DocumentNode.SelectNodes("//div")[0];

            article.Thumbnail = nodes.SelectSingleNode(".//a//div//img").GetAttributeValue("src", "").Substring("//tn.hitomi.la/".Length);

            return(article);
        }
Beispiel #2
0
        // Current Settings
        //---------
        //<main role="main" class="container">
        //<div class="gallery-content">
        //   <a target="_blank" href="/reader/1192959">
        //   <img src="https://aa.hiyobi.me/tn/1192959.jpg" />
        //   </a>
        //   <span>
        //      <h5><a target="_blank" href="/reader/1192959">
        //         <b>Urara no Makura</b></a>
        //      </h5>
        //      <table>
        //         <tr>
        //            <td>작가 : </td>
        //            <td>
        //               <a target="_blank" href="/search/artist:amanagi_seiji">amanagi seiji</a> (<a target="_blank" href="/search/group:ins-mode">ins-mode</a>)
        //            </td>
        //         </tr>
        //         <tr>
        //            <td>원작 : </td>
        //            <td>N/A</td>
        //         </tr>
        //         <tr>
        //            <td>
        //               종류 :
        //            </td>
        //            <td><a target='_blank' href='/search/type:doujinshi'>동인지</a></td>
        //         </tr>
        //         <tr>
        //            <td>
        //               태그 :
        //            </td>
        //            <td><a target="_blank" data-original="female:anal" href="/search/female:anal">
        //               애널 ♀</a> <a target="_blank" data-original="female:lingerie" href="/search/female:lingerie">
        //               란제리 ♀</a> <a target="_blank" data-original="female:sex toys" href="/search/female:sex_toys">
        //               성기구 ♀</a> <a target="_blank" data-original="female:sole female" href="/search/female:sole_female">
        //               단독 여성 ♀</a> <a target="_blank" data-original="female:stockings" href="/search/female:stockings">
        //               스타킹 ♀</a>
        //            </td>
        //         </tr>
        //      </table>
        //   </span>
        //</div>
        //---------
        static public List <HitomiArticle> ParseInfo(string source)
        {
            List <HitomiArticle> result   = new List <HitomiArticle>();
            HtmlDocument         document = new HtmlDocument();

            document.LoadHtml(source);

            HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//div[@class='gallery-content']");

            if (nodes == null)
            {
                return(result);
            }

            foreach (HtmlNode node in nodes)
            {
                HitomiArticle article = new HitomiArticle();
                article.Magic     = node.SelectSingleNode(".//a[@target='_blank']").GetAttributeValue("href", "").Split('/')[2];
                article.Thumbnail = node.SelectSingleNode(".//img").GetAttributeValue("src", "");

                article.Title   = node.SelectSingleNode(".//h5//b").InnerText;
                article.Artists = node.SelectSingleNode(".//a[contains(@href, '/search/artist:')]")?.InnerText;
                article.Groups  = node.SelectSingleNode(".//a[contains(@href, '/search/group:')]")?.InnerText;

                article.Series = node.SelectNodes(".//tr")[1].SelectNodes(".//td")[1].InnerText;
                article.Types  = node.SelectSingleNode(".//a[contains(@href, '/search/type:')]").InnerText;

                article.TagsKor = true;
                List <string>      tags     = new List <string>();
                HtmlNodeCollection tagsnode = node.SelectNodes(".//tr")[3].SelectNodes(".//a");
                if (tagsnode != null)
                {
                    foreach (HtmlNode tag in tagsnode)
                    {
                        tags.Add(tag.InnerText + "|" + tag.GetAttributeValue("href", "").Split('/')[2]);
                    }
                }
                result.Add(article);
            }

            return(result);
        }
Beispiel #3
0
        static public List <HitomiArticle> ParseArticles(string source)
        {
            List <HitomiArticle> result = new List <HitomiArticle>();
            // Get total blocks
            Regex regex = new Regex(article_block, RegexOptions.Multiline);
            Match match = regex.Match(source);

            while (match.Success)
            {
                HitomiArticle article = new HitomiArticle();

                string block1 = match.Groups[1].Value;
                article.Magic     = getMatch1(block1_magic, block1);
                article.Thumbnail = getMatch1(block1_thumbnail, block1);

                string block2 = match.Groups[2].Value;
                article.Title         = replaceEntity(getMatch1(block2_title, block2));
                article.OriginalTitle = article.Title;
                article.Artists       = new string[] { artist_legalize(getMatch1(block2_artist, block2)) }; // get only first artist

                string block3 = match.Groups[3].Value;
                article.Series   = new string[] { series_legalize(getMatch1(block3_series, block3)) };
                article.Types    = getMatch1(block3_type, block3);
                article.Language = getMatch1(block3_language, block3);

                Regex         regex_tags = new Regex(block3_tags, RegexOptions.Multiline);
                Match         match_tags = regex_tags.Match(block3);
                List <string> tags       = new List <string>();
                while (match_tags.Success)
                {
                    tags.Add(match_tags.Groups[1].Value);
                    match_tags = match_tags.NextMatch();
                }
                article.Tags = tags.ToArray();

                result.Add(article);
                match = match.NextMatch();
            }

            return(result);
        }