SkyNovels: fix novels & searchTerm

This commit is contained in:
Rajarshee Chatterjee
2021-06-01 22:19:25 +05:30
parent b011cbff32
commit 0c399e663e
+13 -19
View File
@@ -6,28 +6,22 @@ const { parseHtml } = require("../../helper");
const baseUrl = "https://www.skynovels.net/"; const baseUrl = "https://www.skynovels.net/";
const novelsScraper = async (req, res) => { const novelsScraper = async (req, res) => {
let url = baseUrl + "novelas"; const url = "https://api.skynovels.net/api/novels?&q";
const result = await fetch(url); const result = await fetch(url);
const body = await result.text(); const body = await result.json();
$ = cheerio.load(body); const novels = [];
let novels = []; body.novels.map((res) => {
const novelName = res.nvl_title;
const novelCover =
"https://api.skynovels.net/api/get-image/" +
res.image +
"/novels/false";
const novelUrl = res.id + "/" + res.nvl_name + "/";
$(".skn-nvl-card").each(function (result) { const novel = { extensionId: 24, novelName, novelUrl, novelCover };
const novelName = $(this).find(".skn-nvl-card-title").text();
const novelCover = $(this).find("img").attr("src");
let novelUrl = $(this).attr("href").split("/");
novelUrl = novelUrl[2] + "/" + novelUrl[3] + "/";
const novel = {
extensionId: 24,
novelName,
novelCover,
novelUrl,
};
novels.push(novel); novels.push(novel);
}); });
@@ -128,8 +122,8 @@ const chapterScraper = async (req, res) => {
}; };
const searchScraper = async (req, res) => { const searchScraper = async (req, res) => {
const searchTerm = req.query.s; let searchTerm = req.query.s;
searchTerm = searchTerm.toLowerCase();
const url = "https://api.skynovels.net/api/novels?&q"; const url = "https://api.skynovels.net/api/novels?&q";
const result = await fetch(url); const result = await fetch(url);