Home /Phantom JS /Phantom JS - How to Install it on Debian & What it can do /

Phantom JS - How to Install it on Debian & What it can do

2:17 am, April 23, 2017

Original Post Date: 4:03 am, December 8, 2014

So i recently came across PhantomJS. I know its probably been around for a while, but i thought i would give it a go. Its pretty cool.

Heres how i installed it on my Debian server, as it does not have an apt package that i know of.

cd /usr/local/share
sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
sudo tar xjf phantomjs-1.9.7-linux-x86_64.tar.bz2
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs


test that its working with:

phantomjs -v

It should print out its version number: 1.9.7

Right now what can we do with PhantomJS?

Well here is the official list of examples.

Want to take a screen shot of your webpage and save it to a jpg or png? Check out the code below to do it (you can also switch the .jpg for .png if you want a higher quality file:

var page = require('webpage').create(); page.viewportSize = { width: 1200, height: 1080 }; page.open('http://kruxor.com/', function() { page.render('kruxor.jpg'); phantom.exit(); }); // raw version of the install commands: cd /usr/local/share sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 sudo tar xjf phantomjs-1.9.7-linux-x86_64.tar.bz2 sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs sudo ln -s /usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs