Add Wuxiaworld.co (#21)
This commit is contained in:
committed by
GitHub
parent
b5cbd514a2
commit
4e8c355060
@@ -20,6 +20,7 @@ Sources for [LNReader](https://github.com/rajarsheechatterjee/lnreader)
|
|||||||
| WuxiaWorldSite | :heavy_check_mark: |
|
| WuxiaWorldSite | :heavy_check_mark: |
|
||||||
| FreeWebNovel | :heavy_check_mark: |
|
| FreeWebNovel | :heavy_check_mark: |
|
||||||
| JPMTL | :heavy_check_mark: |
|
| JPMTL | :heavy_check_mark: |
|
||||||
|
| WuxiaWorldCo | :heavy_check_mark: |
|
||||||
| LightNovelPub | :heavy_check_mark: |
|
| LightNovelPub | :heavy_check_mark: |
|
||||||
|
|
||||||
## Setup locally
|
## Setup locally
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ app.use("/api/12/", require("./src/en/wuxiaworldsite/WuxiaWorldSite"));
|
|||||||
app.use("/api/13/", require("./src/en/freewebnovel/FreeWebNovel"));
|
app.use("/api/13/", require("./src/en/freewebnovel/FreeWebNovel"));
|
||||||
app.use("/api/14/", require("./src/en/jpmtl/JPMTL"));
|
app.use("/api/14/", require("./src/en/jpmtl/JPMTL"));
|
||||||
app.use("/api/15/", require("./src/en/lightnovelpub/LightNovelPub"));
|
app.use("/api/15/", require("./src/en/lightnovelpub/LightNovelPub"));
|
||||||
|
app.use("/api/16/", require("./src/en/wuxiaworldco/WuxiaWorldCo"));
|
||||||
|
|
||||||
const PORT = process.env.PORT || 5000;
|
const PORT = process.env.PORT || 5000;
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,15 @@ extensions = [
|
|||||||
sourceLanguage: "English",
|
sourceLanguage: "English",
|
||||||
status: 1,
|
status: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
sourceId: 16,
|
||||||
|
sourceUrl: "https://www.wuxiaworld.co/",
|
||||||
|
sourceName: "WuxiaWorldCo",
|
||||||
|
sourceCover:
|
||||||
|
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/wuxiaworldco/icon.png?raw=true",
|
||||||
|
sourceLanguage: "English",
|
||||||
|
status: 1,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
sourceId: 15,
|
sourceId: 15,
|
||||||
sourceUrl: "https://www.lightnovelpub.com/",
|
sourceUrl: "https://www.lightnovelpub.com/",
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const wuxiaWorldCoScraper = require("./WuxiaWorldCoScraper");
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.get("/novels/", wuxiaWorldCoScraper.novelsScraper);
|
||||||
|
|
||||||
|
router.get("/novel/:novelUrl", wuxiaWorldCoScraper.novelScraper);
|
||||||
|
|
||||||
|
router.get("/novel/:novelUrl/:chapterUrl", wuxiaWorldCoScraper.chapterScraper);
|
||||||
|
|
||||||
|
router.get("/search/", wuxiaWorldCoScraper.searchScraper);
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
const cheerio = require("cheerio");
|
||||||
|
const fetch = require("node-fetch");
|
||||||
|
const { htmlToText } = require("html-to-text");
|
||||||
|
|
||||||
|
const baseUrl = "https://www.wuxiaworld.co/";
|
||||||
|
|
||||||
|
const novelsScraper = async (req, res) => {
|
||||||
|
const result = await fetch(baseUrl);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
$(".section-item").each(function (result) {
|
||||||
|
const novelName = $(this).find(".book-name").text();
|
||||||
|
const novelCover = $(this).find("img").attr("src");
|
||||||
|
|
||||||
|
let novelUrl = $(this).find("a").attr("href").slice(1);
|
||||||
|
|
||||||
|
const novel = {
|
||||||
|
extensionId: 16,
|
||||||
|
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);
|
||||||
|
|
||||||
|
let novel = {};
|
||||||
|
|
||||||
|
novel.extensionId = 16;
|
||||||
|
|
||||||
|
novel.sourceName = "WuxiaWorldCo";
|
||||||
|
|
||||||
|
novel.sourceUrl = url;
|
||||||
|
|
||||||
|
novel.novelUrl = `${novelUrl}/`;
|
||||||
|
|
||||||
|
novel.novelName = $(".book-name").text();
|
||||||
|
|
||||||
|
novel.novelCover = $("div.book-img > img").attr("src");
|
||||||
|
|
||||||
|
novel["Genre(s)"] = $("div.book-catalog > span.txt").text();
|
||||||
|
|
||||||
|
novel.Status = $("div.book-state > span.txt").text();
|
||||||
|
|
||||||
|
novel["Author(s)"] = $("div.author > span.name").text();
|
||||||
|
|
||||||
|
novelSummary = $("div.content > p.desc").html();
|
||||||
|
novel.novelSummary = htmlToText(novelSummary);
|
||||||
|
|
||||||
|
let novelChapters = [];
|
||||||
|
|
||||||
|
$(".chapter-item").each(function (result) {
|
||||||
|
const chapterName = $(this).find(".chapter-name").text();
|
||||||
|
const releaseDate = null;
|
||||||
|
const chapterUrl = $(this)
|
||||||
|
.attr("href")
|
||||||
|
.replace("/" + novelUrl + "/", "");
|
||||||
|
|
||||||
|
novelChapters.push({
|
||||||
|
chapterName,
|
||||||
|
releaseDate,
|
||||||
|
chapterUrl,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
novel.novelChapters = novelChapters;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
const chapterName = $("h1.chapter-title").text();
|
||||||
|
let chapterText = $("div.chapter-entity").html();
|
||||||
|
chapterText = htmlToText(chapterText);
|
||||||
|
|
||||||
|
let nextChapter = null;
|
||||||
|
|
||||||
|
if ($("a.next").length) {
|
||||||
|
nextChapter = $("a.next")
|
||||||
|
.attr("href")
|
||||||
|
.replace("/" + novelUrl + "/", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
let prevChapter = null;
|
||||||
|
|
||||||
|
if ($("a.prev").length) {
|
||||||
|
prevChapter = $("a.prev")
|
||||||
|
.attr("href")
|
||||||
|
.replace("/" + novelUrl + "/", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
novelUrl = novelUrl + "/";
|
||||||
|
chapterUrl = chapterUrl + "/";
|
||||||
|
|
||||||
|
const chapter = {
|
||||||
|
extensionId: 16,
|
||||||
|
novelUrl,
|
||||||
|
chapterUrl,
|
||||||
|
chapterName,
|
||||||
|
chapterText,
|
||||||
|
nextChapter,
|
||||||
|
prevChapter,
|
||||||
|
};
|
||||||
|
|
||||||
|
res.json(chapter);
|
||||||
|
};
|
||||||
|
|
||||||
|
const searchScraper = async (req, res) => {
|
||||||
|
const searchTerm = req.query.s;
|
||||||
|
|
||||||
|
const url = `${baseUrl}search/${searchTerm}/1`;
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
$(".list-item").each(function (result) {
|
||||||
|
$(this).find("font").remove();
|
||||||
|
|
||||||
|
const novelName = $(this).find(".book-name").text();
|
||||||
|
const novelCover = $(this).find("img").attr("src");
|
||||||
|
|
||||||
|
let novelUrl = $(this).find("a").attr("href").slice(1);
|
||||||
|
|
||||||
|
const novel = {
|
||||||
|
extensionId: 16,
|
||||||
|
novelName,
|
||||||
|
novelCover,
|
||||||
|
novelUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
novels.push(novel);
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(novels);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = wuxiaWorldCoScraper = {
|
||||||
|
novelsScraper,
|
||||||
|
novelScraper,
|
||||||
|
chapterScraper,
|
||||||
|
searchScraper,
|
||||||
|
};
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
Reference in New Issue
Block a user