Saturday 7 September 2019

How to get visual DOM structure from url in node.js

I am wondering how to get "visual" DOM structure from url in node.js. When I try to get html content with request library, html structure is not correct.

const request = require('request');
const jsdom = require("jsdom");
const { JSDOM } = jsdom;

request({ 'https://www.washingtonpost.com/news/acts-of-faith/wp/2017/06/30/trump-promised-to-destroy-the-johnson-amendment-congress-is-targeting-it-now/', jar: true }, function (e, r, body) {
  console.log(body);
});

reurned html structure is here, where meta tags are not correct:

<meta property="og:title" content=""/>
<meta itemprop="description" name="description" content=""/>

If I open website in web browser, I can see correct meta tags in web inspector:

<meta property="og:title" content="Trump promised to destroy the Johnson Amendment. Congress is targeting it now."/>

<meta itemprop="description" name="description" content="Observers believe the proposed legislation would make it harder for the IRS to enforce a law preventing pulpit endorsements."/>



from How to get visual DOM structure from url in node.js

No comments:

Post a Comment