Esempio n. 1
0
        public static DCGallery ParseMinorGallery(string html)
        {
            DCGallery gall = new DCGallery();

            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(html);
            HtmlNode node = document.DocumentNode.SelectNodes("//tbody")[0];

            gall.id       = document.DocumentNode.SelectSingleNode("//input[@id='gallery_id']").GetAttributeValue("value", "");
            gall.name     = document.DocumentNode.SelectSingleNode("//meta[@property='og:title']").GetAttributeValue("content", "");
            gall.esno     = document.DocumentNode.SelectSingleNode("//input[@id='e_s_n_o']").GetAttributeValue("value", "");
            gall.cur_page = document.DocumentNode.SelectSingleNode("//div[@class='bottom_paging_box']/em").InnerText;
            try { gall.max_page = document.DocumentNode.SelectSingleNode("//a[@class='page_end']").GetAttributeValue("href", "").Split('=').Last(); } catch { }

            List <DCPageArticle> pas = new List <DCPageArticle>();

            foreach (var tr in node.SelectNodes("./tr"))
            {
                try
                {
                    var gall_num = tr.SelectSingleNode("./td[1]").InnerText;
                    int v;
                    if (!int.TryParse(gall_num, out v))
                    {
                        continue;
                    }

                    var pa = new DCPageArticle();
                    pa.no       = gall_num;
                    pa.classify = tr.SelectSingleNode("./td[2]").InnerText;
                    pa.type     = tr.SelectSingleNode("./td[3]/a/em").GetAttributeValue("class", "").Split(' ')[1];
                    pa.title    = tr.SelectSingleNode("./td[3]/a").InnerText;
                    try { pa.replay_num = tr.SelectSingleNode(".//span[@class='reply_num']").InnerText; } catch { }
                    pa.nick = tr.SelectSingleNode("./td[4]").GetAttributeValue("data-nick", "");
                    pa.uid  = tr.SelectSingleNode("./td[4]").GetAttributeValue("data-uid", "");
                    pa.ip   = tr.SelectSingleNode("./td[4]").GetAttributeValue("data-ip", "");
                    if (pa.ip == "")
                    {
                        pa.islogined = true;
                        if (tr.SelectSingleNode("./td[4]/a/img").GetAttributeValue("src", "").Contains("fix_nik.gif"))
                        {
                            pa.isfixed = true;
                        }
                    }
                    pa.date      = DateTime.Parse(tr.SelectSingleNode("./td[5]").GetAttributeValue("title", ""));
                    pa.count     = tr.SelectSingleNode("./td[6]").InnerText;
                    pa.recommend = tr.SelectSingleNode("./td[7]").InnerText;

                    pas.Add(pa);
                }
                catch { }
            }

            gall.articles = pas.ToArray();

            return(gall);
        }
Esempio n. 2
0
        public static DCComment GetComments(DCGallery g, DCPageArticle 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", g.id);
            wc.Query.Add("no", article.no);
            wc.Query.Add("cmt_id", g.id);
            wc.Query.Add("cmt_no", article.no);
            wc.Query.Add("e_s_n_o", g.esno);
            wc.Query.Add("comment_page", page);
            return(JsonConvert.DeserializeObject <DCComment>(NetTools.DownloadStringAsync(wc).Result));
        }