Wednesday, July 3, 2019

Screenshot of a website



PhantomJS Installation

Install PhantomJS on Ubuntu
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
sudo apt-get install libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/
sudo ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin
phantomjs --version
2.1.1

mkdir /path/to/screenshot
cd /path/to/screenshot
Copy rasterize.js in the directory where you want the resulting screenshot to take place.
wget https://raw.githubusercontent.com/ariya/phantomjs/master/examples/rasterize.js
phantomjs --debug=yes --ignore-ssl-errors=true --ssl-protocol=any --web-security=true rasterize.js https://enews.ssis.edu.vn enews.png "400px*300px" .25

The last variable is the zoom factor of the website.  In this case .25 means 25% of the website in a 400px by 300px thumbnail.