I
I
Ivan Ivanovich2021-07-27 13:23:43
Node.js
Ivan Ivanovich, 2021-07-27 13:23:43

How to work with HTML in NodeJS?

Good day.

An html code arrives from the client, which needs to be processed on the server.

The following tasks are on the server.

  • Collect pictures, get their height, width, write them to the appropriate attributes of the img tag
  • Add target="_blank" to all links


etc.

These are just examples of tasks.

So which HTML package should I choose? I found the two most optimal at first glance, these are https://www.npmjs.com/package/node-html-parser and https://www.npmjs.com/package/jsdom .

Maybe you have worked with similar cases, advise what is better to choose.

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-07-27
@IwanQ

https://github.com/cheeriojs/cheerio

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question