|
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:
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. |