nodejs将html转换成json

const fs = require('fs')
const { parser } = require('posthtml-parser')

const html = fs.readFileSync('test.html', 'utf-8')
const result = parser(html)
fs.writeFile('./ast.json', JSON.stringify(result), 'utf-8', function(error) {
	console.log('写入成功');
});

你可能感兴趣的:(工程化,json,html,前端)