public override Task UpdateRecentChapters(LibraryViewModel l) { var d = Dispatcher.CurrentDispatcher; return Task.Factory.StartNew(() => { var v = new WebClient(); String downloadedPage = DownloadManager.DownloadPage(@"http://www.mangahere.com/latest/"); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(downloadedPage); foreach (HtmlNode itemManga in htmlDoc.DocumentNode.SelectNodes(@"/html/body/section[@class='page_main']/div[@class='latest_released']/div[@class='manga_updates']/dl")) { var mangaNode = itemManga.SelectSingleNode(@"dt"); var mangaName = mangaNode.SelectSingleNode("a").InnerText; var mangaDetailLink = mangaNode.SelectSingleNode("a").GetAttributeValue("href", ""); MangaViewModel manga = new MangaViewModel { Name = mangaName }; DetailMangaSource detailMangaSource = new MangaHereDetailMangaSource { DetailMangaLink = mangaDetailLink }; manga.Sources.Add(detailMangaSource); d.Invoke(() => manga = l.UpdateOrCreateManga(manga)); foreach (var itemChapter in itemManga.SelectNodes("dd")) { var matches = Regex.Matches(itemChapter.SelectSingleNode("a").InnerText, @"\d+"); var chapterName = matches[matches.Count - 1].Value; var chapterLink = mangaNode.SelectSingleNode("a").GetAttributeValue("href", ""); ChapterViewModel chapter = new ChapterViewModel { Name = chapterName }; chapter.Sources.Add(new MangaHereChapterSource { ChapterLink = chapterLink }); d.Invoke(() => manga.UpdateOrCreateChapter(chapter)); } manga.Name = mangaName; } }); }
public override Task UpdateRecentChapters(LibraryViewModel l) { Dispatcher d = Dispatcher.CurrentDispatcher; return Task.Factory.StartNew(() => { String downloadedPage = DownloadManager.DownloadPage(@"http://www.mangareader.net/latest"); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(downloadedPage); foreach (HtmlNode itemManga in htmlDoc.DocumentNode.SelectNodes(@"html/body/div[@id='container']/div[@id='wrapper_body']/div[@id='latest']/div[@id='latestchapters']/table[@class='updates']/tr/td[2]")) { var mangaNode = itemManga.SelectSingleNode(@"a[@class='chapter']"); var mangaName = mangaNode.InnerText; var mangaDetailLink = "http://www.mangareader.net" + mangaNode.GetAttributeValue("href", ""); MangaViewModel manga = new MangaViewModel { Name = mangaName }; d.Invoke(() => manga.Sources.Add(new MangaReaderDetailMangaSource { DetailMangaLink = mangaDetailLink })); d.Invoke(() => manga = l.UpdateOrCreateManga(manga)); foreach (var itemChapter in itemManga.SelectNodes(@"a[@class='chaptersrec']")) { var matches = Regex.Matches(itemChapter.InnerText, @"\d+"); var chapterName = matches[matches.Count - 1].Value; var chapterLink = itemChapter.GetAttributeValue("href", ""); ChapterViewModel chapter = new ChapterViewModel { Name = chapterName }; chapter.Sources.Add(new MangaReaderChapterSource { ChapterLink = chapterLink }); d.Invoke(() => manga.UpdateOrCreateChapter(chapter)); } } }); }