wuxia.blog: Fix chapters

This commit is contained in:
Rajarshee Chatterjee
2021-07-09 09:29:54 +05:30
parent 15001adf70
commit 081920c3b1
+29 -3
View File
@@ -104,6 +104,35 @@ const novelScraper = async (req, res) => {
novelChapters.push(chapter); 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(); novel.novelChapters = novelChapters.reverse();
res.json(novel); res.json(novel);
@@ -115,7 +144,6 @@ const chapterScraper = async (req, res) => {
let chapterUrl = req.params.chapterUrl; let chapterUrl = req.params.chapterUrl;
const url = `${baseUrl}novel/${novelUrl}/${chapterId}/${chapterUrl}`; const url = `${baseUrl}novel/${novelUrl}/${chapterId}/${chapterUrl}`;
console.log(url);
const result = await fetch(url); const result = await fetch(url);
const body = await result.text(); const body = await result.text();
@@ -153,8 +181,6 @@ const searchScraper = async (req, res) => {
const url = `${baseUrl}?search=${searchTerm}`; const url = `${baseUrl}?search=${searchTerm}`;
console.log(url);
const result = await fetch(url); const result = await fetch(url);
const body = await result.text(); const body = await result.text();