private void HTMLChapterListParse(List<Webpage> pages) { LightNovelDownloadList.Items.Clear(); foreach (Webpage page in pages) { #region japtem if (page.link.Contains("japtem")) { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(page.html); var data = from nodes in doc.DocumentNode.Descendants("article") where nodes.Attributes["class"].Value.ToString().Contains("post hentry") select nodes; HtmlAgilityPack.HtmlNode[] dataarray = data.ToArray(); for (int j = dataarray.Count() - 1; j >= 0; j--) { HtmlAgilityPack.HtmlDocument entry = new HtmlAgilityPack.HtmlDocument(); entry.LoadHtml(dataarray[j].InnerHtml); var entrydata = from innernodes in entry.DocumentNode.Descendants("a") where innernodes.Attributes["href"] != null select innernodes; HtmlAgilityPack.HtmlNode[] entrydatarray = entrydata.ToArray(); for (int i = entrydatarray.Count() - 1; i >= 0; i--) { if (entrydatarray[i].InnerHtml.IndexOf("Chapter") > 0) { foreach (LightNovel chaptertest in page.Lightnovels) { Console.WriteLine(chaptertest.Title.ToLower()); Console.WriteLine(entrydata.ToArray()[i].InnerHtml.ToLower()); if (chaptertest.Title.ToLower().Contains(entrydata.ToArray()[i].InnerHtml.ToLower().Split(':')[0])) { chaptertest.addChapter(new Chapter(entrydatarray[i].Attributes["href"].Value, entrydata.ToArray()[i].InnerHtml)); } } LightNovelDownloadList.Items.Add(new Chapter(entrydatarray[i].Attributes["href"].Value, entrydata.ToArray()[i].InnerHtml)); } } entry = null; } doc = null; } #endregion if (page.link.Contains("baka-tsuki")) { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(page.html); var data = doc.DocumentNode.Descendants("dl").Select(a => a.Descendants("a")); int volume = 1; int i = 1; foreach (var dataitems in data) { if(i % 2 != 0) { Chapter chapter = null; foreach (var dataitem in dataitems) { if (dataitem.Attributes["class"] != null) { if(dataitem.Attributes["class"].Value.Contains("external")) { chapter = new Chapter(dataitem.Attributes["href"].Value, "Volume " + volume + " " + dataitem.InnerHtml); } else { if (!(dataitem.Attributes["title"].Value.Contains("page does not exist"))) { if(!(dataitem.Attributes["title"].Value.ToLower().Contains("user"))) { chapter = new Chapter("https://www.baka-tsuki.org" + dataitem.Attributes["href"].Value, dataitem.Attributes["title"].Value); } } } } else { if (!(dataitem.Attributes["title"].Value.Contains("page does not exist"))) { if (!(dataitem.Attributes["title"].Value.ToLower().Contains("user"))) { chapter = new Chapter("https://www.baka-tsuki.org" + dataitem.Attributes["href"].Value, dataitem.Attributes["title"].Value); } } } if(chapter != null) { foreach (LightNovel chaptertest in page.Lightnovels) { if (chaptertest.Title.ToLower().Contains(chapter.Title.ToLower().Split(':')[0])) { chaptertest.addChapter(chapter); } } LightNovelDownloadList.Items.Add(chapter); } chapter = null; } volume++; } i++; } } } }
public void addChapter(Chapter flup) { chapters.Add(flup); }