Using phantomjs to check different parameters of a site.
Installing the module
sudo yum install fontconfig freetype libfreetype.so.6 libfontconfig.so.1 libstdc++.so.6
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-i686.tar.bz2
tar jxvf phantomjs-1.9.7-linux-i686.tar.bz2
mv phantomjs-1.9.7-linux-x86_64 phantomjs
Installing the module
sudo yum install fontconfig freetype libfreetype.so.6 libfontconfig.so.1 libstdc++.so.6
tar jxvf phantomjs-1.9.7-linux-i686.tar.bz2
mv phantomjs-1.9.7-linux-x86_64 phantomjs
export PATH=$PATH:/root/phantomjs/bin/
In the phantomjs directory there are examples for js script. We use a test script provided by them for checking the load speed of site.
phantomjs loadspeed.js http://www.adminz.in
Page title is Linux Conquering Cloud
Loading time 4559 msec
Basic examples
- arguments.js shows the arguments passed to the script
- countdown.js prints a 10 second countdown
- echoToFile.js writes the command line arguments to a file
- fibo.js lists the first few numbers in the Fibonacci sequence
- hello.js displays the famous message
- module.js and
universe.js
demonstrate the use of module system - outputEncoding.js displays a string in various encodings
- printenv.js displays the system's environment variables
- scandir.js lists all files in a directory and its subdirectories
- sleepsort.js sorts integers and delays display depending on their values
- version.js prints out PhantomJS version number
- page_events.js prints out page events firing: useful to better grasp
page.on*
callbacks
Rendering/rasterization
- colorwheel.js creates a color wheel using HTML5 canvas
- rasterize.js rasterizes a web page to image or PDF
- rendermultiurl.js renders multiple web pages to images
- technews.js captures Google News as a PNG image
Page automation
- direction.js uses Google Maps to print driving direction
- follow.js shows the number of followers of some Twitter accounts
- imagebin.js uploads an image to imagebin.org
- injectme.js injects itself into a web page context
- ipgeocode.js deduces the location via IP geocoding
- movies.js lists movies from kids-in-mind.com
- phantomwebintro.js uses jQuery to read #intro element text from phantomjs.org
- pizza.js uses yelp.com to find pizza places in Mountain View
- seasonfood.js displays the BBC seasonal food list
- tweets.js displays the most recent tweets
- unrandomize.js modifies a global object at page initialization
- waitfor.js waits until a test condition is true or a timeout occurs
Network
- detectsniff.js detects if a web page sniffs the user agent
- loadspeed.js computes the loading speed of a web site
- netlog.js dumps all network requests and responses
- netsniff.js captures network traffic in HAR format
- post.js sends an HTTP POST request to a test server
- postserver.js starts a web server and sends an HTTP POST request to it
- server.js starts a web server and sends an HTTP GET request to it
- serverkeepalive.js starts a web server which answers in plain text
- simpleserver.js starts a web server which answers in HTML