A server browser that can execute JavaScript

Are there any programming libraries available that will parse an HTML document, execute JavaScript, and then allow me to navigate the DOM? This must be done on the server side, not on the client side. Any language will work, but it is preferable to use Java, PHP or Ruby.

+7
java javascript browser ruby php
source share
9 answers

in java: http://lobobrowser.org/cobra/java-html-parser.jsp

it is a javascript-enabled HTML parser that supports CSS

the most important feature regarding your question: this is Javascript. DOM changes that occur during parsing will be reflected as a result of the DOM.

+2
source share
+6
source share

Java has javascript support with Rhino, also look at this page for server-side solutions: http://en.wikipedia.org/wiki/Server-side_JavaScript

+2
source share

For Java, be sure to check out HtmlUnit and HttpUnit .

+1
source share

PhantomJS does this and can be used with any server-side language. See Some Integration Modules below for NodeJS and PHP

NodeJS

https://npmjs.org/package/node-phantom

https://github.com/sgentle/phantomjs-node

Php

https://github.com/diggin/php-PhantomjsRunner

+1
source share

PHP has a DOMDocument for navigating the DOM. I have not heard anything about JavaScript execution.

0
source share

Start with this post and follow the links. Or just find Rhino.

0
source share

Now there are several projects that do a really good job of this:

  • PhantomJS is a headless version of WebKit, and there are some useful wrappers like CasperJS .

  • Zombie.js , which is a wrapper over jsdom , written in Javascript (Node.js).

You need to write JavaScript code to interact with both of these projects. I like Zombie.js better so far, since it is easier to set up, and you can use any Node.js / npm modules in your code.

0
source share

node.js?

Node can run any javascript file in the console. First I'll try node and see if it can do what you want, since it probably has the largest user base and documentation.

0
source share

All Articles