add FreeWebNovel (#15)
* add FreeWebNovel * fix sourceId * fix chapterName
This commit is contained in:
committed by
GitHub
parent
977a8cc412
commit
5b673d714d
@@ -30,6 +30,7 @@ app.use("/api/9/", require("./src/en/noveltrench/NovelTrench"));
|
|||||||
app.use("/api/10/", require("./src/en/vipnovel/VipNovel"));
|
app.use("/api/10/", require("./src/en/vipnovel/VipNovel"));
|
||||||
app.use("/api/11/", require("./src/en/kisslightnovels/KissLightNovels"));
|
app.use("/api/11/", require("./src/en/kisslightnovels/KissLightNovels"));
|
||||||
app.use("/api/12/", require("./src/en/wuxiaworldsite/WuxiaWorldSite"));
|
app.use("/api/12/", require("./src/en/wuxiaworldsite/WuxiaWorldSite"));
|
||||||
|
app.use("/api/13/", require("./src/en/freewebnovel/FreeWebNovel"));
|
||||||
|
|
||||||
const PORT = process.env.PORT || 5000;
|
const PORT = process.env.PORT || 5000;
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,15 @@ extensions = [
|
|||||||
sourceLanguage: "English",
|
sourceLanguage: "English",
|
||||||
status: 1,
|
status: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
sourceId: 13,
|
||||||
|
sourceUrl: "https://freewebnovel.com/",
|
||||||
|
sourceName: "FreeWebNovel",
|
||||||
|
sourceCover:
|
||||||
|
"https://github.com/rajarsheechatterjee/lnreader-extensions/blob/main/src/en/freewebnovel/icon.png?raw=true",
|
||||||
|
sourceLanguage: "English",
|
||||||
|
status: 1,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = extensions;
|
module.exports = extensions;
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
const express = require("express");
|
||||||
|
const freeWebNovelScraper = require("./FreeWebNovelScraper");
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
router.get("/novels/", freeWebNovelScraper.novelsScraper);
|
||||||
|
|
||||||
|
router.get("/novel/:novelUrl", freeWebNovelScraper.novelScraper);
|
||||||
|
|
||||||
|
router.get("/novel/:novelUrl/:chapterUrl", freeWebNovelScraper.chapterScraper);
|
||||||
|
|
||||||
|
router.get("/search/", freeWebNovelScraper.searchScraper);
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
const cheerio = require("cheerio");
|
||||||
|
const fetch = require("node-fetch");
|
||||||
|
const request = require("request");
|
||||||
|
const { htmlToText } = require("html-to-text");
|
||||||
|
|
||||||
|
const baseUrl = "https://freewebnovel.com/";
|
||||||
|
|
||||||
|
const novelsScraper = async (req, res) => {
|
||||||
|
let url = baseUrl + "most-popular-novel/";
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
$(".li-row").each(function (result) {
|
||||||
|
const novelName = $(this).find(".tit").text();
|
||||||
|
const novelCover = $(this).find("img").attr("src");
|
||||||
|
|
||||||
|
let novelUrl = $(this)
|
||||||
|
.find("h3 > a")
|
||||||
|
.attr("href")
|
||||||
|
.replace(".html", "")
|
||||||
|
.slice(1);
|
||||||
|
|
||||||
|
novelUrl += "/";
|
||||||
|
|
||||||
|
const novel = {
|
||||||
|
extensionId: 13,
|
||||||
|
novelName,
|
||||||
|
novelCover,
|
||||||
|
novelUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
novels.push(novel);
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(novels);
|
||||||
|
};
|
||||||
|
|
||||||
|
const novelScraper = async (req, res) => {
|
||||||
|
const novelUrl = req.params.novelUrl;
|
||||||
|
const url = `${baseUrl}${novelUrl}.html`;
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novel = {};
|
||||||
|
|
||||||
|
novel.extensionId = 13;
|
||||||
|
|
||||||
|
novel.sourceName = "FreeWebNovel";
|
||||||
|
|
||||||
|
novel.sourceUrl = url;
|
||||||
|
|
||||||
|
novel.novelUrl = `${novelUrl.replace(".html", "")}/`;
|
||||||
|
|
||||||
|
novel.novelName = $("h1.tit").text();
|
||||||
|
|
||||||
|
novel.novelCover = $(".pic > img").attr("src");
|
||||||
|
|
||||||
|
novel["Genre(s)"] = $("[title=Genre]")
|
||||||
|
.next()
|
||||||
|
.text()
|
||||||
|
.replace(/[\t\n]/g, "");
|
||||||
|
|
||||||
|
novel["Author(s)"] = $("[title=Author]")
|
||||||
|
.next()
|
||||||
|
.text()
|
||||||
|
.replace(/[\t\n]/g, "");
|
||||||
|
|
||||||
|
novel["Artist(s)"] = null;
|
||||||
|
|
||||||
|
novel.Status = $("[title=Status]")
|
||||||
|
.next()
|
||||||
|
.text()
|
||||||
|
.replace(/[\t\n]/g, "");
|
||||||
|
|
||||||
|
novel.Alternative = $("[title='Alternative names']")
|
||||||
|
.next()
|
||||||
|
.text()
|
||||||
|
.replace(/[\t\n]/g, "");
|
||||||
|
|
||||||
|
let novelSummary = $(".inner").html();
|
||||||
|
novel.novelSummary = htmlToText(novelSummary);
|
||||||
|
|
||||||
|
let novelChapters = [];
|
||||||
|
|
||||||
|
let latestChapter = $(".m-newest1 > ul > li")
|
||||||
|
.first()
|
||||||
|
.text()
|
||||||
|
.match(/Chapter (\d*)/);
|
||||||
|
|
||||||
|
latestChapter = latestChapter[1];
|
||||||
|
|
||||||
|
for (let i = 0; i <= parseInt(latestChapter); i++) {
|
||||||
|
const chapterName = "Chapter " + i;
|
||||||
|
|
||||||
|
const releaseDate = null;
|
||||||
|
|
||||||
|
const chapterUrl = "chapter-" + i;
|
||||||
|
|
||||||
|
const chapter = { chapterName, releaseDate, chapterUrl };
|
||||||
|
|
||||||
|
novelChapters.push(chapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
novel.novelChapters = novelChapters.reverse();
|
||||||
|
|
||||||
|
res.json(novel);
|
||||||
|
};
|
||||||
|
|
||||||
|
const chapterScraper = async (req, res) => {
|
||||||
|
let novelUrl = req.params.novelUrl;
|
||||||
|
let chapterUrl = req.params.chapterUrl;
|
||||||
|
|
||||||
|
const url = `${baseUrl}${novelUrl}/${chapterUrl}.html`;
|
||||||
|
|
||||||
|
const result = await fetch(url);
|
||||||
|
const body = await result.text();
|
||||||
|
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let chapterName = $("h1.tit").text();
|
||||||
|
|
||||||
|
let chapterText = $("div.txt").html();
|
||||||
|
chapterText = htmlToText(chapterText);
|
||||||
|
|
||||||
|
let nextChapter = null;
|
||||||
|
|
||||||
|
if ($("[title='Read Next chapter']").length) {
|
||||||
|
nextChapter = $("[title='Read Next chapter']")
|
||||||
|
.attr("href")
|
||||||
|
.replace("/" + novelUrl + "/", "")
|
||||||
|
.replace(".html", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
let prevChapter = null;
|
||||||
|
|
||||||
|
if ($("[title='Read Privious Chapter']").length) {
|
||||||
|
prevChapter = $("[title='Read Privious Chapter']")
|
||||||
|
.attr("href")
|
||||||
|
.replace("/" + novelUrl + "/", "")
|
||||||
|
.replace(".html", "");
|
||||||
|
}
|
||||||
|
novelUrl = novelUrl + "/";
|
||||||
|
chapterUrl = chapterUrl;
|
||||||
|
|
||||||
|
const chapter = {
|
||||||
|
extensionId: 13,
|
||||||
|
novelUrl,
|
||||||
|
chapterUrl,
|
||||||
|
chapterName,
|
||||||
|
chapterText,
|
||||||
|
nextChapter,
|
||||||
|
prevChapter,
|
||||||
|
};
|
||||||
|
|
||||||
|
res.json(chapter);
|
||||||
|
};
|
||||||
|
|
||||||
|
const searchScraper = async (req, res) => {
|
||||||
|
const searchTerm = req.query.s;
|
||||||
|
|
||||||
|
const url = baseUrl + "search/";
|
||||||
|
|
||||||
|
request.post(
|
||||||
|
{ url, form: { searchkey: searchTerm } },
|
||||||
|
(err, response, body) => {
|
||||||
|
$ = cheerio.load(body);
|
||||||
|
|
||||||
|
let novels = [];
|
||||||
|
|
||||||
|
$(".li-row > .li > .con").each(function (result) {
|
||||||
|
const novelName = $(this).find(".tit").text();
|
||||||
|
const novelCover = $(this)
|
||||||
|
.find(".pic > a > img")
|
||||||
|
.attr("data-cfsrc");
|
||||||
|
|
||||||
|
let novelUrl = $(this)
|
||||||
|
.find("h3 > a")
|
||||||
|
.attr("href")
|
||||||
|
.replace(".html", "")
|
||||||
|
.slice(1);
|
||||||
|
|
||||||
|
novelUrl += "/";
|
||||||
|
|
||||||
|
const novel = {
|
||||||
|
extensionId: 13,
|
||||||
|
novelName,
|
||||||
|
novelCover,
|
||||||
|
novelUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
novels.push(novel);
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(novels);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = vipNovelScraper = {
|
||||||
|
novelsScraper,
|
||||||
|
novelScraper,
|
||||||
|
chapterScraper,
|
||||||
|
searchScraper,
|
||||||
|
};
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
Reference in New Issue
Block a user