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); }
public static DCComment GetComments(DCGallery g, DCPageArticle article, string page) { var wc = Net.NetCommon.GetDefaultClient(); wc.Headers.Add("X-Requested-With", "XMLHttpRequest"); wc.QueryString.Add("id", g.id); wc.QueryString.Add("no", article.no); wc.QueryString.Add("cmt_id", g.id); wc.QueryString.Add("cmt_no", article.no); wc.QueryString.Add("e_s_n_o", g.esno); wc.QueryString.Add("comment_page", page); return(JsonConvert.DeserializeObject <DCComment>(Encoding.UTF8.GetString(wc.UploadValues("https://gall.dcinside.com/board/comment/", "POST", wc.QueryString)))); }