Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Examples

ariya edited this page Sep 23, 2012 · 20 revisions

PhantomJS comes with a lot of included examples. Often an example comes in two flavors: JavaScript and CoffeScript.

Basic examples

  • hello.js displays the famous message
  • version.js prints out PhantomJS version number
  • arguments.js shows the arguments passed to the script
  • fibo.js lists the first few numbers in the Fibonacci sequence
  • module.js and universe.js demonstrates the use of module system

Rendering/rasterization

  • rasterize.js rasterizes a web page to image or PDF
  • colorwheel.js creates a color wheel using HTML5 canvas
  • technews.js captures Google News as a PNG image

Page automation

  • direction.js uses Google Maps to print driving direction
  • ipgeocode.js deduces the location via IP geocoding
  • follow.js shows the number of follower of some Twitter accounts
  • tweets.js displays the most recent tweets

Network

  • 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

(More to be written)

Clone this wiki locally