Phantomjs is a webkit with javascript api which means using phantomjs we can load web pages emulating like a webkit based browser without any GUI.
In simple words for understanding, Phantomjs can access and load webpages behaving like a normal browser.It can render webpages exactly same as browser which is the unique and foremost feature of phantomjs.Developers call this concept as headless webkit.
Why Phantomjs?
Page processing is often tedious or either incomplete in other technologies.Phantomjs offers the flexibility of page rendering without the actual user interface.Not just works on webpages it also can render html5 canvas and SVG.
Phantomjs is opensource and was developed by ariya.It comes in different versions based on the server operating system.You can download the binary or build it using the source code.
Uses
- Phantomjs is used for taking screenshots of webpages and converting them to pdf.
- Website testing
- Network monitoring- Generate HAR files to get the network and other data.
Usage example
1 2 3 4 5 6 7 | console.log('Loading a web page'); var page = require('webpage').create(); var url = 'http://www.phantomjs.org/'; page.open(url, function (status) { //Page is loaded! phantom.exit(); }); |
Read further
Hope you understood the introduction of phantomjs.But this does not end here because there are steps in between in setting up the server and try out a working example.