Created
November 25, 2018 04:36
-
-
Save wahengchang/09fd3f80dd62765d8324fc1851a50f61 to your computer and use it in GitHub Desktop.
decode html-entities
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
// example of fetching a | |
(async function(){ | |
const fetch = require('node-fetch') | |
const fs = require('fs') | |
const cheerio = require('cheerio') | |
const html = await fetch(`http://www.macaodaily.com/html/2018-11/25/node_2.htm`).then(res => res.text()) | |
const path = `./temp/${year}-${month}` | |
if (!fs.existsSync(path)) { | |
fs.mkdirSync(path); | |
} | |
fs.writeFileSync(`./today.html`, html) | |
//<a id="pageLink" href="node_2.htm">第A01版:澳聞</a> | |
// the decode the result | |
// require('html-entities').XmlEntities.decode(html) | |
//<a id="pageLink" href="node_2.htm">第A01版:澳聞</a> | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment