Skip to main content
100%

Take a snapshot of a page with phantom JS

✓ Published0🌍 Public
LLeeMendelowitz
Last edited Feb 25, 2015
Created on Feb 25, 2015

This example captures a static snapshot of a live web page using PhantomJS. It loads the DC Metro Metrics daily service report for February 23, 2015, then waits five seconds before writing the rendered HTML content to standard output, producing a full page dump. The code relies on PhantomJS’s `webpage` and `system` modules, setting a Chrome user-agent and using `page.open` with a callback and `setTimeout` to ensure the page finishes rendering. The result is a saved HTML file that preserves the report’s final visual state.

AI-generated description

To run, download PhantomJS

From the terminal:

phantomjs snapshot.js > output.html

Similar vizzes