BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / screenshot-stream / readme.md

readme.md

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
readme.md 2.5 KiB Download Raw

screenshot-stream Build Status

> Capture screenshot of a website and return it as a stream

Install

$ npm install --save screenshot-stream

Usage

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

const 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.

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.

timeout

Type: number (seconds)
Default: 60

Number of seconds after which PhantomJS aborts the request.

selector

Type: string

Capture a specific DOM element.

css

Type: string

Apply custom CSS to the webpage. Specify some CSS or the path to a CSS file.

script

Type: string

Apply custom JavaScript to the webpage. Specify some JavaScript or the path to a file.

hide

Type: Array

Hide an array of DOM elements.

headers

Type: Object
Default: {}

Set custom headers.

cookies

Type: Array or 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 jpg.

scale

Type: number
Default: 1

Scale webpage n times.

userAgent

Type: string

Set a custom user agent.

transparent

Type: Boolean
Default: false

Set background color to transparent instead of white if no background is set.

.on('error', callback)

Type: Function

PhantomJS errors.

.on('warning', callback)

Type: Function

Warnings with for example page errors.

CLI

See the pageres CLI.

License

MIT © Kevin Mårtensson

Source
1# screenshot-stream [![Build Status](https://travis-ci.org/kevva/screenshot-stream.svg?branch=master)](https://travis-ci.org/kevva/screenshot-stream)
2
3> Capture screenshot of a website and return it as a stream
4
5
6## Install
7
8```
9$ npm install --save screenshot-stream
10```
11
12
13## Usage
14
15```js
16const fs = require('fs');
17const screenshot = require('screenshot-stream');
18
19const stream = screenshot('http://google.com', '1024x768', {crop: true});
20
21stream.pipe(fs.createWriteStream('google.com-1024x768.png'));
22```
23
24
25## API
26
27### screenshot(url, size, [options])
28
29#### url
30
31Type: `string`
32
33Add page to capture.
34
35#### size
36
37Type: `string`
38
39Set viewport size.
40
41#### options
42
43Type: `Object`
44
45Define options to be used.
46
47##### crop
48
49Type: `Boolean`<br>
50Default: `false`
51
52Crop to the set height.
53
54##### delay
55
56Type: `number` *(seconds)*<br>
57Default: `0`
58
59Delay capturing the screenshot. Useful when the site does things after load that you want to capture.
60
61##### timeout
62
63Type: `number` *(seconds)*<br>
64Default: `60`
65
66Number of seconds after which PhantomJS aborts the request.
67
68##### selector
69
70Type: `string`
71
72Capture a specific DOM element.
73
74##### css
75
76Type: `string`
77
78Apply custom CSS to the webpage. Specify some CSS or the path to a CSS file.
79
80##### script
81
82Type: `string`
83
84Apply custom JavaScript to the webpage. Specify some JavaScript or the path to a file.
85
86##### hide
87
88Type: `Array`
89
90Hide an array of DOM elements.
91
92##### headers
93
94Type: `Object`<br>
95Default: `{}`
96
97Set custom headers.
98
99##### cookies
100
101Type: `Array` or `Object`
102
103A string with the same format as a [browser cookie](http://en.wikipedia.org/wiki/HTTP_cookie) or an object of what [`phantomjs.addCookie`](http://phantomjs.org/api/phantom/method/add-cookie.html) accepts.
104
105##### username
106
107Type: `string`
108
109Username for authenticating with HTTP auth.
110
111##### password
112
113Type: `string`
114
115Password for authenticating with HTTP auth.
116
117##### format
118
119Type: `string`<br>
120Default: `png`
121
122Set format to render the image as. Supported formats are `png` and `jpg`.
123
124##### scale
125
126Type: `number`<br>
127Default: `1`
128
129Scale webpage `n` times.
130
131##### userAgent
132
133Type: `string`
134
135Set a custom user agent.
136
137##### transparent
138
139Type: `Boolean`<br>
140Default: `false`
141
142Set background color to `transparent` instead of `white` if no background is set.
143
144#### .on('error', callback)
145
146Type: `Function`
147
148PhantomJS errors.
149
150#### .on('warning', callback)
151
152Type: `Function`
153
154Warnings with for example page errors.
155
156
157## CLI
158
159See the [pageres](https://github.com/sindresorhus/pageres#usage) CLI.
160
161
162## License
163
164MIT © [Kevin Mårtensson](https://github.com/kevva)