Created
November 22, 2019 00:03
-
-
Save victusfate/d3c91e6fdfff885b75acaedf92c3d2bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require('cheerio') | |
const fs = require('fs') | |
const sData = fs.readFileSync('./spells/Aberrant_Whispers.html').toString() | |
let $ = cheerio.load(sData) | |
$('a').each(function(i,elem) { | |
let link = $(this) | |
const text = $(this).text() | |
link.after(text) | |
link.remove() | |
}) | |
let pagecontent = $('#pagecontent').html() | |
// let pagecontent1 = pagecontent.replace('<p>', '') | |
// pagecontent1 = pagecontent1.replace('</p>', '\n') | |
// pagecontent1 = pagecontent1.replace('<br>', '\n') | |
// pagecontent1 = pagecontent1.replace('<b>', '\n') | |
// pagecontent1 = pagecontent1.replace('</b>', '\n') | |
console.log(pagecontent) | |
// https://www.npmjs.com/package/cheerio | |
let pageContentPost = '' | |
$(pagecontent).each(function(i, ielem) { | |
const sTest = $(this).html() | |
console.log('sTest',sTest) | |
if ($(this).is('a')) { | |
const sData = $(this).text() | |
console.log('an a element',sData) | |
if (sData) { | |
console.log('an a element',sData) | |
pageContentPost = pageContentPost + sData | |
} | |
} | |
else { | |
const sData = $(this).html() | |
if (sData) { | |
pageContentPost = pageContentPost + sData | |
} | |
} | |
}) | |
// console.log(pageContentPost) | |
console.log('') | |
$(pageContentPost).each(function(i, ielem) { | |
console.log($(this).text()) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment