node.js - Node js - Trying to send POST request, but it is not loading javascript content -


i have been trying send post request website, , has not been loading full site.

i guessing problem node js not loading javascript content, executing it. can see javascript in response, though never loads content javascript files producing in html.

what mean is, doesn't execute javascript. how make node js code overcome this, , wait the full website load? have tried native code, , "request' module, both producing same errors. if helps, don't need native javascript. modules fine.

some code have tried (request module):

var options = { method: 'post', uri: 'https://url', formdata: {     'email': 'email',     'prize': '0',     'transactional': 'on' }, headers: {     /* 'content-type': 'application/x-www-form-urlencoded' */ // set automatically } };  rp(options) .then(function (body) {    console.log(body) }) .catch(function (err) {    console.log(err) }); 

when fetch contents of url or post , response, response text. node.js not parse content. not execute javascript in content. that's browser - node.js not browser. so, raw content downloaded browser form website. if it's html response, raw html page , no embedded scripts fetched or run.

if want page parsed , scripts run in it, need component can use inside of node.js mimics browser does. it's not hard html parser, it's lot more work fetch , run javascript in page , safely in way not put server @ risk. in fact, google doesn't run javascript when indexing web pages (though have been working on technology circumstances).

jsdom , cheerio couple modules can use in node.js parsing html response, jsdom execute scripts in page, cheerio not.

another package use phantomjs can serve webkit-based, headless browser can communicate node.js.


Comments

Popular posts from this blog

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -