PHANTOMJS is a WebKit-based server-side JavaScript API. It fully supports the web without the need for browser support, its fast, native support for various web standards: DOM processing, CSS selectors, JSON, Canvas, and SVG. PHANTOMJS can be used for page automation, network monitoring, web screen screenshots, and no interface testing, etc.
1. Download the appropriate version with 64-bit Linux as an example
mkdir DOWNLOADCD downloadwget https: // bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
2. Decompression and Installation
TAR-XJVF phantomjs-2.1. 1-linux-x86_64.tar.bz2
MV Phantomjs-2.1.1-linux-x86_64/usr/local/phantomjs
Ln-s/usr/local/phantomjs/bin/phantomjs/usr/local/bin
3. Test
Phantomjs-v
Write a simple script:
var page = require ('webpage'). Create ();p age.open ('http ://www.aifei.com/', function () { page.render ('aifei.png') ); Phantom.exit ();})
Perform a look:
Phantomjs A.js
Look at the resulting PNG image:
Look carefully, the Chinese font is garbled (or not)
Install a font dependency
Yum Install bitmap-fonts BITMAP-FONTS-CJK
Execute the script again after loading
Phantomjs A.jssz Aifei.png
It worked!
Done
Website address:
http://phantomjs.org
Linux. Installing PHANTOMJS