Skip to content

Instantly share code, notes, and snippets.

@wahengchang
Created November 25, 2018 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wahengchang/09fd3f80dd62765d8324fc1851a50f61 to your computer and use it in GitHub Desktop.
Save wahengchang/09fd3f80dd62765d8324fc1851a50f61 to your computer and use it in GitHub Desktop.
decode html-entities
// 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">&#x7B2C;A01&#x7248;&#xFF1A;&#x6FB3;&#x805E;</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