原文
https://www.darklaunch.com/parse-html-string-with-node-js-jquery-and-jsdom.html
安裝
yarn add jsdom jquery
--
var jsdom = require('jsdom');
var dom = new jsdom.JSDOM();
var window = dom.window;
var document = window.document;
var $ = require('jquery')(window);
console.log('version:', $.fn.jquery);
var $content = $('<p><a href="[https://www.example.com/](https://www.example.com/)">Link</a></p>');
console.log('text:', $content.text());
console.log('html:', $content.html());
console.log('href:', $content.find('a').attr('href'));