Add WuxiaWorldSite (#14)
* Add WuxiaWorldSite * Remove novelID * Replace Puppeteer method with ajax call
This commit is contained in:
@@ -29,6 +29,7 @@ app.use("/api/8/", require("./src/en/novelfull/NovelFull"));
|
||||
app.use("/api/9/", require("./src/en/noveltrench/NovelTrench"));
|
||||
app.use("/api/10/", require("./src/en/vipnovel/VipNovel"));
|
||||
app.use("/api/11/", require("./src/en/kisslightnovels/KissLightNovels"));
|
||||
app.use("/api/12/", require("./src/en/wuxiaworldsite/WuxiaWorldSite"));
|
||||
|
||||
const PORT = process.env.PORT || 5000;
|
||||
|
||||
|
||||
@@ -98,6 +98,15 @@ extensions = [
|
||||
sourceLanguage: "English",
|
||||
status: 1,
|
||||
},
|
||||
{
|
||||
sourceId: 12,
|
||||
sourceUrl: "https://wuxiaworldsite.co/",
|
||||
sourceName: "WuxiaWorldSite",
|
||||
sourceCover:
|
||||
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworldsite/icon.png?raw=true",
|
||||
sourceLanguage: "English",
|
||||
status: 1,
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = extensions;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const express = require("express");
|
||||
const WuxiaWorldScraper = require("./WuxiaWorldSiteScraper");
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/novels/", WuxiaWorldSiteScraper.novelsScraper);
|
||||
|
||||
router.get("/novel/:novelUrl", WuxiaWorldSiteScraper.novelScraper);
|
||||
|
||||
router.get("/novel/:novelUrl/:chapterUrl", WuxiaWorldSiteScraper.chapterScraper);
|
||||
|
||||
router.get("/search/", WuxiaWorldSiteScraper.searchScraper);
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,202 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
const baseUrl = "https://wuxiaworldsite.co/";
|
||||
const searchUrl = "https://wuxiaworldsite.co/search/";
|
||||
|
||||
const novelsScraper = async (req, res) => {
|
||||
const url = `${baseUrl}/power-ranking`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$(".a_item").each( (i, el) => {
|
||||
const novelName = $(el).find("a").attr("title");
|
||||
const novelCover = baseUrl + $(el).find("a > img").attr("src");
|
||||
const novelUrl = $(el).find(".name_views > a").attr("href");
|
||||
|
||||
const novel = {
|
||||
extensionId: 12,
|
||||
novelName,
|
||||
novelCover,
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
res.json(novels);
|
||||
}
|
||||
|
||||
const novelScraper = async (req, res) => {
|
||||
const novelUrl = req.params.novelUrl;
|
||||
const url = `${baseUrl}${novelUrl}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
|
||||
$(".category_list").remove();
|
||||
|
||||
let novel = {};
|
||||
|
||||
novel.extensionId = 12;
|
||||
|
||||
novel.sourceName = "WuxiaWorldSite";
|
||||
|
||||
novel.sourceUrl = url;
|
||||
|
||||
novel.novelUrl = novelUrl + "/";
|
||||
|
||||
novel.novelName = $(".content-reading > h1").text();
|
||||
|
||||
novel.novelCover = baseUrl + $(".img-read> img").attr("src");
|
||||
|
||||
novel.novelSummary = $(".story-introduction-content").text();
|
||||
|
||||
novel["Author(s)"] = $(".content-reading > p").text();
|
||||
|
||||
novel["Artist(s)"] = null;
|
||||
|
||||
novel["Genre(s)"] = "";
|
||||
|
||||
$(".a_tag_item").each((i, el) => {
|
||||
novel["Genre(s)"] += $(el).text() + ",";
|
||||
});
|
||||
|
||||
novel["Genre(s)"] = novel["Genre(s)"].split(",");
|
||||
novel["Genre(s)"].pop();
|
||||
|
||||
novel.Status = novel["Genre(s)"].pop();
|
||||
|
||||
novel["Genre(s)"] = novel["Genre(s)"].join(",");
|
||||
|
||||
const novelID = $(".show-more-list").attr("data-id");
|
||||
|
||||
const getChapters = async (novelID) => {
|
||||
const chapterListUrl = baseUrl + "/get-full-list.ajax?id=" + novelID;
|
||||
|
||||
const data = await fetch(chapterListUrl);
|
||||
const chapters = await data.text();
|
||||
|
||||
$ = cheerio.load(chapters);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
$(".new-update-content").each((i, el) => {
|
||||
let chapterName = $(el).text().split(/\t+/);
|
||||
const releaseDate = chapterName.pop();
|
||||
chapterName = chapterName[0];
|
||||
let chapterUrl = $(el).attr("href");
|
||||
chapterUrl = chapterUrl.split("/").pop();
|
||||
|
||||
const novel = {
|
||||
chapterName,
|
||||
releaseDate,
|
||||
chapterUrl,
|
||||
};
|
||||
novelChapters.push(novel);
|
||||
});
|
||||
return novelChapters;
|
||||
};
|
||||
|
||||
novel.novelChapters = await getChapters(novelID);
|
||||
|
||||
res.json(novel);
|
||||
};
|
||||
|
||||
const chapterScraper = async (req, res) => {
|
||||
let novelUrl = req.params.novelUrl;
|
||||
let chapterUrl = req.params.chapterUrl;
|
||||
|
||||
const url = `${baseUrl}/${novelUrl}/${chapterUrl}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
|
||||
let chapterText = $("#content").html() || "";
|
||||
let chapterName = "";
|
||||
if (chapterText) {
|
||||
chapterText = chapterText.split("<br>");
|
||||
chapterName = chapterText.shift();
|
||||
} else {
|
||||
$("p").each((i, el) => {
|
||||
if ($(el).css("display") !== "none") {
|
||||
chapterText += $(el).text() + "\n";
|
||||
}
|
||||
});
|
||||
chapterText = chapterText.split("\n");
|
||||
chapterName = chapterText.shift();
|
||||
}
|
||||
|
||||
chapterText = chapterText.join("\n");
|
||||
|
||||
const prevChapter = $(".pre").attr("href")
|
||||
? $(".pre").attr("href").split("/").pop()
|
||||
: null;
|
||||
|
||||
const nextChapter = $(".next_sesction > a").attr("href")
|
||||
? $(".next_sesction > a").attr("href").split("/").pop()
|
||||
: null;
|
||||
|
||||
|
||||
novelUrl += "/";
|
||||
chapterUrl += "/";
|
||||
|
||||
const chapter = {
|
||||
extensionId: 12,
|
||||
novelUrl,
|
||||
chapterUrl,
|
||||
chapterName,
|
||||
chapterText,
|
||||
nextChapter,
|
||||
prevChapter,
|
||||
};
|
||||
|
||||
res.json(chapter);
|
||||
};
|
||||
|
||||
const searchScraper = async (req, res) => {
|
||||
const searchTerm = req.query.s;
|
||||
|
||||
const url = `${searchUrl}${searchTerm}`;
|
||||
|
||||
const result = await fetch(url);
|
||||
const body = await result.text();
|
||||
|
||||
$ = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
$(".a_item").each( (i, el) => {
|
||||
const novelName = $(el).find(".name_views > a").attr("title");
|
||||
const novelCover = baseUrl + $(el).find("a > img").attr("src");
|
||||
const novelUrl = $(el).find(".name_views > a").attr("href");
|
||||
|
||||
const novel = {
|
||||
extensionId: 12,
|
||||
novelName,
|
||||
novelCover,
|
||||
novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
res.json(novels)
|
||||
};
|
||||
|
||||
|
||||
module.exports = WuxiaWorldSiteScraper = {
|
||||
novelsScraper,
|
||||
novelScraper,
|
||||
chapterScraper,
|
||||
searchScraper,
|
||||
};
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 145 KiB |
Reference in New Issue
Block a user