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