From d46d7b014e501a8d845bc68d6028f257edf6b2b6 Mon Sep 17 00:00:00 2001 From: TakenPt Date: Wed, 3 Apr 2024 03:18:29 +0900 Subject: [PATCH] =?UTF-8?q?#22=20=E3=81=AA=E3=82=8D=E3=81=86=E3=81=AE?= =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=88=E3=81=A7=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Epub/KoeBook.Epub/Services/ScrapingNaroService.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs b/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs index 2fd47d0..9d4d0cc 100644 --- a/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs +++ b/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs @@ -41,6 +41,10 @@ public async ValueTask ScrapingAsync(string url, string coverFileP doc = await context.OpenAsync(request => request.Content(html), ct).ConfigureAwait(false); } + // 何らかの原因で、なろうのサイトでエラーが発生した場合エラー + if (doc.QuerySelector("#contents_main h1")?.InnerHtml == "エラー") + throw new EbookException(ExceptionType.WebScrapingFailed, "ページを読み込めませんでした。URLを確認してください。"); + // title の取得 var bookTitleElement = doc.QuerySelector(".novel_title") ?? throw new EbookException(ExceptionType.WebScrapingFailed, $"タイトルを取得できませんでした");