From e8ca1bbd0aad16becf5e2db28755bb2d972e3db5 Mon Sep 17 00:00:00 2001 From: Oleg Koloskov Date: Fri, 3 Nov 2023 13:22:59 +0300 Subject: [PATCH] fix studentlibrary --- Parsers/StudentLibrary.Parser/Logic/Parser.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Parsers/StudentLibrary.Parser/Logic/Parser.cs b/Parsers/StudentLibrary.Parser/Logic/Parser.cs index c7dba3f..7e8a232 100644 --- a/Parsers/StudentLibrary.Parser/Logic/Parser.cs +++ b/Parsers/StudentLibrary.Parser/Logic/Parser.cs @@ -29,7 +29,7 @@ private async Task GetBook(HttpClient client, Uri uri) { } var id = uri.Segments.Last().Split(".")[0]; - var detailedDescriptionBlock = doc.DocumentNode.GetByFilterFirst("div", "reader-info"); + var detailedDescriptionBlock = doc.DocumentNode.GetByFilterFirst("div", "book_sticker_book"); var book = new BookInfo(id, ElsName) { Name = doc.DocumentNode.GetByFilterFirst("h2")?.InnerText }; @@ -54,8 +54,8 @@ private async Task GetBook(HttpClient client, Uri uri) { .Split(' ') .First(), out book.Pages); if(value.Contains("ISBN")) { - book.ISBN = value.Split(new []{ "ISBN" }, StringSplitOptions.None)[1].Trim() - .Split(new []{ ". " }, StringSplitOptions.None) + book.ISBN = value.Split(new []{ "ISBN"}, StringSplitOptions.None)[1].Trim() + .Split(new []{ ", " }, StringSplitOptions.None) .First(); } } else if (name.Contains("Издательство")) { @@ -75,7 +75,7 @@ private static async Task> GetBookLinks(HttpClient client, Uri return doc == default ? Enumerable.Empty() - : doc.DocumentNode.GetByFilter("div", "wrap-title-book-sengine") + : doc.DocumentNode.GetByFilter("div", "book_sticker_sengine_librarian_right_coll") .Select(div => div.GetByFilterFirst("a") ?.Attributes["href"] ?.Value) @@ -84,12 +84,10 @@ private static async Task> GetBookLinks(HttpClient client, Uri private static async Task GetMaxPageCount(HttpClient client, Uri uri) { var doc = await client.GetHtmlDoc(uri); - - return doc == default + var a = doc.DocumentNode.GetByFilterFirst("a", "a_jmp_page"); + return a == default ? 1 - : doc.DocumentNode.GetByFilterFirst("ul", "pagination-ros-num va-m") - ?.ChildNodes.Select(node => int.TryParse(node.InnerText, out var page) ? page : 1) - .Max() ?? 1; + : int.TryParse(a.InnerText, out var pages) ? pages : 1; } private static IEnumerable Filter(IEnumerable uris, ISet processed) {