2

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?

Hamid Mohayeji
  • 3,977
  • 3
  • 43
  • 55
  • 2
    You 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 Answers2

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
0

Maybe it's too late, but back in the day, PhantomJS solved my problem.

Hamid Mohayeji
  • 3,977
  • 3
  • 43
  • 55