public static BookInfo GetAllChapters(string index) { Console.WriteLine("获取漫画详情"); BookInfo ret = new BookInfo(); ret.Chapters = new List <Chapter>(); try { //var cc = new CookieContainer(); //Console.WriteLine("获取Cookie"); //var cookies = Utils.HtmlManager.GetCookies(index); //ret.Cookie = cc; //for (int i = 0; i < cookies.Count; i++) //{ // cc.Add(cookies[i]); //} Console.WriteLine("获取详情"); var content = Utils.HtmlManager.GetHtmlContentViaUrl(index); if (content.Success) { Console.WriteLine("获取详情成功"); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(content.Content); var titlePath = "//div[@class=\"info\"]/h1"; var titleNode = doc.DocumentNode.SelectSingleNode(titlePath); Console.WriteLine("解析标题"); if (titleNode != null) { var title = titleNode.InnerText; Console.WriteLine("标题 -> " + title); ret.BookName = title; Console.WriteLine("解析章节"); var chaptersPath = "//div[@id=\"chapterlistload\"]/ul/li"; var chaptersNodes = doc.DocumentNode.SelectNodes(chaptersPath); foreach (var c in chaptersNodes) { Chapter chapter = new Chapter { ChapterName = c.InnerText.Trim().Substring(0, c.InnerText.Trim().LastIndexOf("话") + 1), ChapterUrl = c.ChildNodes["a"].Attributes["href"].Value }; Console.WriteLine("章节 -> " + chapter.ChapterName); ret.Chapters.Add(chapter); } } } else { Console.WriteLine("获取详情失败"); } } catch (Exception ee) { Console.WriteLine(ee.ToString()); } return(ret); }