5

So, I have my Node.js script. And I have some HTML page which contains HTML with JavaScript (jquery) in it. How can I load it and get result of execution of JavaScript on this page?

alexeypro
  • 3,633
  • 7
  • 36
  • 49
  • 1
    If screen scraping is what your after, check out: http://blog.nodejitsu.com/jsdom-jquery-in-5-lines-on-nodejs – Brandon Boone Mar 07 '11 at 16:56
  • My HTML page does some manipulations with divs -- and I need to get the result of those manipulations. It's not the screenscrapping to get the source HTML w/ Javascript, but actually the result of their execution. – alexeypro Mar 07 '11 at 17:15

3 Answers3

5

You can check the zombie.js project : http://zombie.labnotes.org/

It should load the page mostly as in a real browser.

Jerome WAGNER
  • 21,986
  • 8
  • 62
  • 77
4

Something like JSDOM should do it.

https://github.com/tmpvar/jsdom

Mark Bolusmjak
  • 23,606
  • 10
  • 74
  • 129
  • 2
    Right, but can't figure out how to I get not just HTML/JS of the window, but the result of their execution there. – alexeypro Mar 07 '11 at 17:16
1

Also, a great solution is https://github.com/GoogleChrome/puppeteer. Which is Headless Chrome Node API and maintained by Chrome DevTools team.

pocheptsov
  • 1,936
  • 20
  • 24