From 787dde7469efb4ea602089a3ea421a185b614dd4 Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Mon, 31 May 2021 09:28:11 +0530 Subject: [PATCH] Foxaholic: Fix novelUrl & chapterUrl --- src/en/foxaholic/FoxaholicScraper.js | 33 +++++++++++++++------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/en/foxaholic/FoxaholicScraper.js b/src/en/foxaholic/FoxaholicScraper.js index de09a85..cb7bbee 100644 --- a/src/en/foxaholic/FoxaholicScraper.js +++ b/src/en/foxaholic/FoxaholicScraper.js @@ -19,8 +19,8 @@ const novelsScraper = async (req, res) => { const novelName = $(this).find(".h5 > a").text(); const novelCover = $(this).find("img").attr("data-src"); - let novelUrl = $(this).find(".h5 > a").attr("href"); - novelUrl = novelUrl.replace(`${baseUrl}novel/`, ""); + let novelUrl = $(this).find(".h5 > a").attr("href").split("/")[4]; + novelUrl += "/"; const novel = { extensionId: 22, @@ -115,7 +115,11 @@ const novelScraper = async (req, res) => { releaseDate = $(this).find("span").text().trim(); - chapterUrl = $(this).find("a").attr("href").replace(url, ""); + chapterUrl = $(this).find("a").attr("href").split("/"); + + chapterUrl[6] + ? (chapterUrl = chapterUrl[5] + "/" + chapterUrl[6]) + : (chapterUrl = chapterUrl[5]); novelChapters.push({ chapterName, releaseDate, chapterUrl }); }); @@ -152,23 +156,23 @@ const chapterScraper = async (req, res) => { let nextChapter = null; if ($(".nav-next").length) { - nextChapter = $(".nav-next") - .find("a") - .attr("href") - .replace(baseUrl + "novel/" + novelUrl + "/", ""); + nextChapter = $(".nav-next").find("a").attr("href").split("/"); + nextChapter[6] + ? (nextChapter = nextChapter[5] + "/" + nextChapter[6]) + : (nextChapter = nextChapter[5]); } let prevChapter = null; if ($(".nav-previous").length) { - prevChapter = $(".nav-previous") - .find("a") - .attr("href") - .replace(baseUrl + "novel/" + novelUrl + "/", ""); + prevChapter = $(".nav-previous").find("a").attr("href").split("/"); + prevChapter[6] + ? (prevChapter = prevChapter[5] + "/" + prevChapter[6]) + : (prevChapter = prevChapter[5]); } novelUrl += "/"; - chapterUrl = optionalUrl + chapterUrl + "/"; + chapterUrl = optionalUrl + chapterUrl; const chapter = { extensionId: 22, @@ -199,9 +203,8 @@ const searchScraper = async (req, res) => { const novelName = $(this).find(".h4 > a").text(); const novelCover = $(this).find("img").attr("data-src"); - let novelUrl = $(this).find(".h4 > a").attr("href"); - novelUrl = novelUrl.replace(`${baseUrl}novel/`, ""); - + let novelUrl = $(this).find(".h4 > a").attr("href").split("/")[4]; + novelUrl += "/"; const novel = { extensionId: 22, novelName,