コード例 #1
0
        public static DCArticle ParseBoardView(string html, bool is_minor = false)
        {
            DCArticle article = new DCArticle();

            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    = node.SelectSingleNode("//span[@class='title_subject']").InnerText;
            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);
        }
コード例 #2
0
        public static DCComment GetComments(DCArticle article, string page)
        {
            var wc = NetTask.MakeDefault("https://gall.dcinside.com/board/comment/");

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