public ParsedManga GetParsedManga(string baseSiteUrl, string mangaUrl) { var parsedMange = new ParsedManga(); var document = GetHtmlDocument(mangaUrl); var mangaRootNode = document.DocumentNode.SelectSingleNode("html"); var body = mangaRootNode.SelectSingleNode("body"); var leftContent = body.SelectSingleNode("//div[@class='leftContent']"); var description = leftContent.SelectSingleNode("//meta[@itemprop='description']"); parsedMange.Description = description.Attributes["content"].Value; var expandable = leftContent.SelectSingleNode("div[@class='expandable']"); var flexRow = expandable.SelectSingleNode("div[@class='flex-row']"); var hrefRoot = flexRow.SelectSingleNode("div[@class='subject-actions col-sm-7']"); var link = hrefRoot.SelectSingleNode("a"); var mangaReaderLink = baseSiteUrl + link.Attributes["href"].Value; parsedMange.Chapters = GetChapters(baseSiteUrl, mangaReaderLink); return(parsedMange); }
public void Test2() { var list = ReadMangaFinder.GetTopMangaList(); var parsedManga = ParsedManga.GetManga(ReadMangaSite, list[0].Url); var chepterPages = parsedManga.Chapters[0].GetMangaPages(ReadMangaSite); }
static void Main(string[] args) { while (true) { MangaSite site = null; MangaFinder mangaFinder = null; Console.WriteLine("ChooseSite MintManga - 1, ReadManga - 2"); var key = Console.ReadKey(); if (key.KeyChar == '1') { site = new MangaSite(MangaSites.MintManga); mangaFinder = new MangaFinder(site); } else { site = new MangaSite(MangaSites.ReadManga); mangaFinder = new MangaFinder(site); } var mangaName = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "mangaName.txt")); Console.WriteLine(mangaName); var list = mangaFinder.GetTopMangaList(); var manga = list.FirstOrDefault(i => i.Name == mangaName); if (manga != null) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("MangaFinded"); Console.ForegroundColor = ConsoleColor.Black; var parsedManga = ParsedManga.GetManga(site, manga.Url); var mangaDirectory = Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), list[11].Name)); int indexChapter = 0; while (indexChapter < parsedManga.Chapters.Count) { try { using (var client = new WebClient()) { var chapter = parsedManga.Chapters[indexChapter]; var chapterDirectory = Directory.CreateDirectory(Path.Combine(mangaDirectory.FullName, indexChapter.ToString())); foreach (var image in chapter.GetMangaPages(site)) { client.DownloadFile(image.PageUrl, Path.Combine(chapterDirectory.FullName, image.PageUrl.Split('/').Last())); } } indexChapter++; Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"Downloaded {indexChapter}"); Console.ForegroundColor = ConsoleColor.Black; } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Exception {ex}"); Console.ForegroundColor = ConsoleColor.Black; Task.Delay(TimeSpan.FromMinutes(10)).Wait(); } } Console.BackgroundColor = ConsoleColor.Green; Console.WriteLine("-----------------------------------DOwnloaded-------------------------------------------"); Console.BackgroundColor = ConsoleColor.Black; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Manga not found"); Console.ForegroundColor = ConsoleColor.Black; } } }