This commit is contained in:
parent
dbe61e793c
commit
2795609ec9
@ -1,9 +1,14 @@
|
||||
const fs = require('fs')
|
||||
const cheerio = require('cheerio')
|
||||
const fetch = require('node-fetch')
|
||||
const epub = require('epub-gen')
|
||||
|
||||
const books = []
|
||||
|
||||
if (!fs.existsSync('output')) {
|
||||
fs.mkdirSync('output')
|
||||
}
|
||||
|
||||
const metadata = (volume) => ({
|
||||
title: `The Wandering Inn - Volume ${volume}`,
|
||||
author: ['Pirateaba'],
|
||||
|
16
livres_fr.js
16
livres_fr.js
@ -1,3 +1,4 @@
|
||||
const fs = require('fs')
|
||||
const cheerio = require('cheerio')
|
||||
const fetch = require('node-fetch')
|
||||
const epub = require('epub-gen')
|
||||
@ -7,6 +8,10 @@ let page = 0
|
||||
const MAX_VOLUME = 3
|
||||
const books = []
|
||||
|
||||
if (!fs.existsSync('output')) {
|
||||
fs.mkdirSync('output')
|
||||
}
|
||||
|
||||
const volume = (post) => post <= 69 ? 1 : post <= 168 ? 2 : MAX_VOLUME
|
||||
|
||||
const metadata = (volume) => ({
|
||||
@ -24,7 +29,7 @@ const metadata = (volume) => ({
|
||||
})
|
||||
|
||||
for (let i = 0; i <= MAX_VOLUME; i++) {
|
||||
books.push(metadata(i))
|
||||
books.push(metadata(i + 1))
|
||||
}
|
||||
|
||||
(async () => {
|
||||
@ -41,17 +46,14 @@ for (let i = 0; i <= MAX_VOLUME; i++) {
|
||||
if (++post === 1) return
|
||||
|
||||
const title = html('div[align=center]', el)
|
||||
|
||||
if (title.html() === null) return
|
||||
|
||||
let text = html('div > div', el)
|
||||
|
||||
text = html(text).attr('style', '')
|
||||
|
||||
const titleText = title.first().html()
|
||||
.replace(/<br>/g, ' ')
|
||||
.replace(/<(\/|)strong>/g, '')
|
||||
.replace(/\*/g, '')
|
||||
const titleFirst = title.first()
|
||||
titleFirst.find('br').replaceWith(' ')
|
||||
const titleText = titleFirst.text().replace(/\*/g, '')
|
||||
|
||||
console.log(`${post} - ${titleText}`)
|
||||
|
||||
|
Reference in New Issue
Block a user