Node: get all text within a div

There are a lot of examples that get you parts of the text on a page, but most of them don’t seem to be able to get nested text.

The easiest way to do this is with jsDom, which is also the heaviest one:

let jsdom = require('jsdom');

let file = 'D:/projects/image-annotation/data/talks/pages/talk200.html';
  (err, window) => {

This will get you the entire text contents within a section of the page, which is ideal if you’re doing scraping.

Leave a Reply

Your email address will not be published. Required fields are marked *