Replace \n between words
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://boxnovel.com/novel";
|
||||
const searchUrl = "https://boxnovel.com/";
|
||||
@@ -127,7 +127,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $("div.text-left > h3").text();
|
||||
let chapterText = $(".reading-content").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const request = require("request");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://freewebnovel.com/";
|
||||
|
||||
@@ -133,7 +134,7 @@ const chapterScraper = async (req, res) => {
|
||||
let chapterName = $("h1.tit").text();
|
||||
|
||||
let chapterText = $("div.txt").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://jpmtl.com/";
|
||||
|
||||
@@ -121,7 +121,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $(".chapter-content__title").text();
|
||||
let chapterText = $(".chapter-content__content").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
let prevChapter = null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://kisslightnovels.info/";
|
||||
|
||||
@@ -119,7 +119,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $("div.text-left > h4").text();
|
||||
let chapterText = $(".reading-content").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
const { scraper } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://www.lightnovelpub.com/";
|
||||
@@ -126,7 +127,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $("h2").text();
|
||||
let chapterText = $("#chapter-container").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://novelfull.com";
|
||||
|
||||
@@ -134,7 +134,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $(".chapter-title").attr("title");
|
||||
let chapterText = $("#chapter-content").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
if ($("a#next_chap").attr("href")) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://www.novelhall.com/";
|
||||
|
||||
@@ -109,7 +109,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $("h1").text();
|
||||
let chapterText = $("div.entry-content").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
nextChapter = $('a[rel="next"]').attr("href");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://noveltrench.com/";
|
||||
|
||||
@@ -119,7 +119,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $("h1#chapter-heading").text();
|
||||
let chapterText = $(".reading-content").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const request = require("request");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://www.readlightnovel.org";
|
||||
const searchUrl = "https://www.readlightnovel.org/detailed-search";
|
||||
@@ -156,7 +156,8 @@ const chapterScraper = async (req, res) => {
|
||||
$(".hidden").remove();
|
||||
|
||||
let chapterText = $(".desc").html();
|
||||
chapterText = htmlToText(chapterText).replace(
|
||||
|
||||
chapterText = parseHtml(chapterText).replace(
|
||||
/\n\nSponsored Content\n\n/g,
|
||||
""
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://readnovelfull.com";
|
||||
|
||||
@@ -134,7 +134,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $(".chr-title").attr("title");
|
||||
let chapterText = $("#chr-content").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
if ($("a#next_chap").attr("href")) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://vipnovel.com/";
|
||||
|
||||
@@ -126,7 +127,7 @@ const chapterScraper = async (req, res) => {
|
||||
}
|
||||
|
||||
let chapterText = $(".text-left").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://www.wuxiaworld.com/";
|
||||
|
||||
@@ -117,7 +117,7 @@ const chapterScraper = async (req, res) => {
|
||||
$("#chapter-content > script").remove();
|
||||
|
||||
let chapterText = $("#chapter-content").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const cheerio = require("cheerio");
|
||||
const fetch = require("node-fetch");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const { parseHtml } = require("../../helper");
|
||||
|
||||
const baseUrl = "https://www.wuxiaworld.co/";
|
||||
|
||||
@@ -95,7 +96,7 @@ const chapterScraper = async (req, res) => {
|
||||
|
||||
const chapterName = $("h1.chapter-title").text();
|
||||
let chapterText = $("div.chapter-entity").html();
|
||||
chapterText = htmlToText(chapterText);
|
||||
chapterText = parseHtml(chapterText);
|
||||
|
||||
let nextChapter = null;
|
||||
|
||||
|
||||
+18
-2
@@ -1,4 +1,5 @@
|
||||
const chromium = require("chrome-aws-lambda");
|
||||
const { htmlToText } = require("html-to-text");
|
||||
const puppeteer = require("puppeteer");
|
||||
const UserAgent = require("user-agents");
|
||||
|
||||
@@ -6,7 +7,12 @@ const userAgent = new UserAgent();
|
||||
|
||||
const scraper = async (url) => {
|
||||
const browser = await puppeteer.launch({
|
||||
args: [...chromium.args, "--hide-scrollbars", "--disable-web-security", "--user-agent=" + userAgent + ""],
|
||||
args: [
|
||||
...chromium.args,
|
||||
"--hide-scrollbars",
|
||||
"--disable-web-security",
|
||||
"--user-agent=" + userAgent + "",
|
||||
],
|
||||
defaultViewport: chromium.defaultViewport,
|
||||
executablePath: await chromium.executablePath,
|
||||
headless: true,
|
||||
@@ -20,4 +26,14 @@ const scraper = async (url) => {
|
||||
return body;
|
||||
};
|
||||
|
||||
module.exports = { scraper };
|
||||
const parseHtml = (html) => {
|
||||
let text = htmlToText(html);
|
||||
text = text.replace(
|
||||
/(?<=[ A-Za-z0-9_@./#&+-])\n(?=[ A-Za-z0-9_@./#&+-])/g,
|
||||
" "
|
||||
);
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
module.exports = { scraper, parseHtml };
|
||||
|
||||
Reference in New Issue
Block a user