PhantomJS provides a headless, yet fully-featured, WebKit browser that can easily be launched off the command-line, and then scripted and manipulated with JavaScript.
confess.js is a small library that uses PhantonJS to make it easy to analyze web pages and apps for various purposes.