Ejemplo n.º 1
0
        public static DCInsideArticle ParseBoardView(string html, bool is_minor = false)
        {
            DCInsideArticle article = new DCInsideArticle();

            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(html);
            HtmlNode node = document.DocumentNode.SelectNodes("//div[@class='view_content_wrap']")[0];

            article.Id                  = Regex.Match(html, @"name=""gallery_no"" value=""(\d+)""").Groups[1].Value;
            article.GalleryName         = Regex.Match(html, @"<h4 class=""block_gallname"">\[(.*?) ").Groups[1].Value;
            article.OriginalGalleryName = document.DocumentNode.SelectSingleNode("//input[@id='gallery_id']").GetAttributeValue("value", "");
            if (is_minor)
            {
                article.Class = node.SelectSingleNode("//span[@class='title_headtext']").InnerText;
            }
            article.Contents     = node.SelectSingleNode("//div[@class='writing_view_box']").InnerHtml;
            article.Title        = HttpUtility.HtmlDecode(node.SelectSingleNode("//span[@class='title_subject']").InnerText);
            article.Views        = node.SelectSingleNode("//span[@class='gall_count']").InnerText.Trim().Split(' ').Last().Replace(",", "");
            article.ReplyCount   = node.SelectSingleNode("//span[@class='gall_reply_num']").InnerText.Trim().Split(' ').Last().Replace(",", "");
            article.CommentCount = node.SelectSingleNode("//span[@class='gall_comment']").InnerText.Trim().Split(' ').Last().Replace(",", "");
            try
            {
                article.ImagesLink = node.SelectNodes("//ul[@class='appending_file']/li").Select(x => x.SelectSingleNode("./a").GetAttributeValue("href", "")).ToList();
                article.FilesName  = node.SelectNodes("//ul[@class='appending_file']/li").Select(x => x.SelectSingleNode("./a").InnerText).ToList();
            }
            catch { }
            article.ESNO = document.DocumentNode.SelectSingleNode("//input[@id='e_s_n_o']").GetAttributeValue("value", "");

            return(article);
        }
Ejemplo n.º 2
0
        public static async Task <DCInsideComment> GetComments(DCInsideArticle article, string page)
        {
            var nt = NetTask.MakeDefault("https://gall.dcinside.com/board/comment/");

            nt.Headers = new Dictionary <string, string>()
            {
                { "X-Requested-With", "XMLHttpRequest" }
            };
            nt.Query = new Dictionary <string, string>()
            {
                { "id", article.OriginalGalleryName },
                { "no", article.Id },
                { "cmt_id", article.OriginalGalleryName },
                { "cmt_no", article.Id },
                { "e_s_n_o", article.ESNO },
                { "comment_page", page }
            };
            return(JsonConvert.DeserializeObject <DCInsideComment>(await NetTools.DownloadStringAsync(nt)));
        }