My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Wiki pages
Links

Official web site: phantomjs.org.

PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, SVG.

PhantomJS is an optimal solution for fast headless testing, site scraping, pages capture, network monitoring and many other use cases.

Here a PhantomJS script which finds pizzeria in Mountain View, along with the address and the telephone number:

var page = new WebPage(),
    url = 'http://lite.yelp.com/search?find_desc=pizza&find_loc=94040&find_submit=Search';

page.open(url, function (status) {
    if (status !== 'success') {
        console.log('Unable to access network');
    } else {
        var results = page.evaluate(function() {
            var list = document.querySelectorAll('span.address'), pizza = [], i;
            for (i = 0; i < list.length; i++) {
                pizza.push(list[i].innerText);
            }
            return pizza;
        });
        console.log(results.join('\n'));
    }
    phantom.exit();
});

PhantomJS scripts can be written in JavaScript or CoffeeScript.

Get the code and build it, and then enjoy some more simple and advanced examples, covering:

  • running regression tests from command line
  • getting driving direction
  • showing weather forecast conditions
  • finding pizza in New York
  • looking up approximate location based on IP address
  • pulling the list of seasonal food
  • producing PDF version of a Wikipedia article
  • rasterizing SVG to image

PhantomJS is multi-platform, it runs on Linux, Windows, FreeBSD, and Mac OS X.

For questions and feedback, please post to phantomjs mailing-list.

PhantomJS is based on Qt. There are two implementations, using C++ and Python.

The logo is from http://www.openclipart.org/detail/17847.

Powered by Google Project Hosting