npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

phantomjs-capture

v0.1.6

Published

Captures Screenshots using Phantom.js

Readme

phantomjs-capture for NodeJS

Simple and lightweight HTML to image capture and html using Node and PhantomJS.

1、Installation

npm install phantomjs-capture

2、Dependencies

  1. node-phantom-simple
  2. mkdirp
  3. commander
  4. colors
  5. Phantom http://phantomjs.org/download.html

The API exposes a single function 'capture'. Using this function, you can input a multitude of settings, which are further specified below:

var capture = require('phantomjs-capture');

capture(options, function(err, result) {

    console.log(result.fullPNGPath);        // PNG PATH
    console.log(result.filePNGName);        // PNG File Name
    console.log(result.fileHTMLPath);       // HTML PATH
    console.log(result.fileHTMLName);       // HTML File Name
});

3、Using on node

You must install phantom from http://phantomjs.org/download.html

3.1、Options

Calling capture() requires an options object, which includes the following definitions:

{
   'url': 'http://ju.taobao.com', // 需要截图的页面的URL,必须的参数; Remote URL, Required.
   'dir': '.', // 输出文件目录; Directory
   'output': 'xxx.png', // 输出文件名; File name
   'size': '1920x768', // 需要截图的页面的宽度x高度, eg: -s 800x600; Captrue width x height, eg: -size 800x600
   'screenTimer': 1000, // 滚屏的时间,如果该时间太短,可能造成一些异步加载的数据未返回时,页面出现空白等,单位:ms。 eg: -t 10000; Screen Timer
   'domHook': 'ju-footer' // DOM上的ID节点,表示此元素出现后将停止截屏,如 <div id="footer"></div>, -hook footer; DOM Hook
}

3.2 Example

test.js

var capture = require('phantomjs-capture');

capture({
    dir: '.',
    output: 'xx.png',
    url: 'http://ju.taobao.com',
    size: '1920x800',
    domHook: 'ju-footer',
    screenTimer: 6000
}, function(err, results){
    console.log(arguments);
});

5、Using on shell

You must install phantom from http://phantomjs.org/download.html

5.1 Command

Usage: capture [options]

Options:

-h, --help                    output usage information
-V, --version                 output the version number
-d, --dir [string]            输出文件目录。eg: -d ./
-o, --output [string]         输出文件名。eg: -o xxx.png
-u, --url [string]            需要截图的页面的URL。eg: -u http://ju.taobao.com
-s, --size [string]           需要截图的页面的宽度x高度, eg: -s 800x600
-dh, --dom-hook [string]      DOM上的ID节点,表示此元素出现后将停止截屏,如 <div id="footer"></div>, -hook footer
-phantomPath, --phantomPath [string] phantomjs的路径, -phantomPath /usr/local/bin/phantomjs
-t, --screen-timer [integer]  滚屏的时间,如果该时间太短,可能造成一些异步加载的数据未返回时,页面出现空白等,单位:ms。 eg: -t 10000

5.2 example

capture --dir . --output xx --url http://ju.taobao.com -size 1920x800 -dom-hook ju-footer -screen-timer 6000 -phantomPath /usr/local/bin/phantomjs

or

capture -d . -o xx -u http://ju.taobao.com -s 1920x800 -dh ju-footer -s 6000