I want to get a html page content from a url using NodeJS after JavaScript is fully loaded and the page is completely rendered, or get the basic html then run all JavaScript files to achieve final content. For example let's assume there is a website based on AngularJS, so the basic html is simple, but after loading all JavaScript codes in the page, page content is completely different. I want to get that final content on my server to find something in it. Any ideas?
Asked
Active
Viewed 3,303 times
2
-
2You need something like [PhantomJS](http://phantomjs.org/) to do it. There is a plenty of wrappers for it on npm. – Leonid Beschastny Mar 31 '15 at 10:51
-
possible duplicate of [How can I scrape pages with dynamic content using node.js?](http://stackoverflow.com/questions/28739098/how-can-i-scrape-pages-with-dynamic-content-using-node-js) – Quentin Mar 31 '15 at 10:52
2 Answers
2
After-Load is a NodeJS package that works like a charm :
var afterLoad=require('after-load');
then :
afterLoad('http://stackoverflow.com/questions/29366718',function(html){
console.log(html.indexOf('charm')>0);
//true
})

Abdennour TOUMI
- 87,526
- 38
- 249
- 254
-
-
`https://www.npmjs.com/package/after-load` but it doesn't work on Windows... – GuiRitter Jun 11 '23 at 00:25
-
really sorry! but i never consider Windows when I do programming ! really sorry – Abdennour TOUMI Jun 11 '23 at 01:31
0
Maybe it's too late, but back in the day, PhantomJS solved my problem.

Hamid Mohayeji
- 3,977
- 3
- 43
- 55