From 081920c3b146a8d870ba7d13a8e47735996c008d Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Fri, 9 Jul 2021 09:29:54 +0530 Subject: [PATCH] wuxia.blog: Fix chapters --- src/en/wuxiablog/WuxiaBlogScraper.js | 32 +++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/en/wuxiablog/WuxiaBlogScraper.js b/src/en/wuxiablog/WuxiaBlogScraper.js index ef0248a..5e8567c 100644 --- a/src/en/wuxiablog/WuxiaBlogScraper.js +++ b/src/en/wuxiablog/WuxiaBlogScraper.js @@ -104,6 +104,35 @@ const novelScraper = async (req, res) => { novelChapters.push(chapter); }); + let moreChaptersUrl = + baseUrl + + "temphtml/_tempChapterList_all_" + + $("div#more").attr("data-nid") + + ".html"; + + let moreChapters = await fetch(moreChaptersUrl); + let moreChaptersString = await moreChapters.text(); + + $ = cheerio.load(moreChaptersString); + + $("a").each(function () { + const chapterName = $(this).text(); + + const releaseDate = $(this)[0] + .nextSibling.nodeValue.replace(/-/g, "/") + .trim(); + + const chapterUrl = $(this).attr("href").replace(url, ""); + + const chapter = { + chapterName, + releaseDate, + chapterUrl, + }; + + novelChapters.push(chapter); + }); + novel.novelChapters = novelChapters.reverse(); res.json(novel); @@ -115,7 +144,6 @@ const chapterScraper = async (req, res) => { let chapterUrl = req.params.chapterUrl; const url = `${baseUrl}novel/${novelUrl}/${chapterId}/${chapterUrl}`; - console.log(url); const result = await fetch(url); const body = await result.text(); @@ -153,8 +181,6 @@ const searchScraper = async (req, res) => { const url = `${baseUrl}?search=${searchTerm}`; - console.log(url); - const result = await fetch(url); const body = await result.text();