mankdev / screenshot-stream

Capture screenshot of a website and return it as a stream

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

screenshot-stream Build Status

Capture screenshot of a website and return it as a stream

Install

$ npm install --save screenshot-stream

Usage

var fs = require('fs');
var screenshot = require('screenshot-stream');

var stream = screenshot('http://google.com', '1024x768', {crop: true});

stream.pipe(fs.createWriteStream('google.com-1024x768.png'));

API

screenshot(url, size, options)

url

Type: String

Add page to capture.

size

Type: String

Set viewport size.

options

Type: Object

Define options to be used.

.on('error', callback)

Type: Function

PhantomJS errors.

.on('warn', callback)

Type: Function

Warnings with eg. page errors.

Options

crop

Type: Boolean
Default: false

Crop to the set height.

delay

Type: Number (seconds)
Default: 0

Delay capturing the screenshot. Useful when the site does things after load that you want to capture.

selector

Type: String

Capture a specific DOM element.

customHeaders

Type: Object
Default: {}

Set custom headers.

cookies

Type: Array|Object

A string with the same format as a browser cookie or an object of what phantomjs.addCookie accepts.

username

Type: String

Username for authenticating with HTTP auth.

password

Type: String

Password for authenticating with HTTP auth.

format

Type: String
Default: png

Set format to render the image as. Supported formats are png and jpeg.

scale

Type: Number
Default: 1

Scale webpage n times.

hide

Type: String|Array

Selector or array of selectors of elements which should be hidden via visibility: hidden right before screen capturing

CLI

See the pageres CLI.

License

MIT © Kevin Mårtensson

About

Capture screenshot of a website and return it as a stream

License:MIT License


Languages

Language:JavaScript 100.0%