I wrote a simple simplified article export tool using NodeJS to export my own simplified article questions to local, along with titles and hyperlinks.

I use NodeJS to make an HTTP request to the following URL, and the response is in HTML format. The details of each article are contained in the HTML LI TAB.

I want to get the entire collection of articles with this line,

document.getElementsByTagName("li");
Copy the code

But you know that the Document API is only available in a browser environment.

So I used this NodeJS library: Jsdom

var request = require('request');
var jsdom = require("jsdom");
var JSDOM = jsdom.JSDOM;
Copy the code

With the help of jsDOM, I can use the Document API in the NodeJS environment as well:

var document = new JSDOM(body).window.document;
        var content = document.getElementsByTagName("li");
Copy the code

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: