You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default the library will be pass a well known list of flags, so probably you don't need any additional setup.
80
86
87
+
### .pool(options)
88
+
89
+
Tha main **browserless** constructor expose a singleton browser. This is enough for most scenarios, but in case you need you can intialize a **pool of instances**.
This method accepts `options` that will be pased to [page.goto](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options).
121
+
#### options
122
+
123
+
See [page.goto](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options).
96
124
97
125
Additionally, you can setup:
98
126
99
-
#### waitFor
127
+
#####waitFor
100
128
101
-
type:`string|function|number`</br>
129
+
type:`string`|`function`|`number`</br>
102
130
default: `0`
103
131
104
132
Wait a quantity of time, selector or function using [page.waitFor](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitforselectororfunctionortimeout-options-args).
Specify a list of events until consider navigation succeeded, using [page.waitForNavigation](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagewaitfornavigationoptions).
112
140
113
-
#### userAgent
141
+
#####userAgent
114
142
115
143
It will setup a custom user agent, using [page.setUserAgent](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetuseragentuseragent) method.
116
144
117
-
#### viewport
145
+
#####viewport
118
146
119
147
It will setup a custom viewport, using [page.setViewport](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetviewportviewport) method.
It returns an [tmpStream](https://github.com/Kikobeats/create-temp-file2#create-temp-file2), with `path` where the temporal file live and `cleanup`/`cleanupSync` methods for clean the temporal file.
173
203
174
-
The `options` provided are passed to [page.pdf](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions).
204
+
#### options
175
205
176
-
If you want to customize tmpStream settings, pass [opts.tmpOptions](https://github.com/Kikobeats/create-temp-file2#createtempfileoptions).
206
+
See [page.pdf](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions).
177
207
178
208
Additionally, you can setup:
179
209
180
-
#### media
210
+
##### tmpOptions
211
+
212
+
See [createTempFile#options](https://github.com/Kikobeats/create-temp-file2#createtempfileoptions).
213
+
214
+
##### media
181
215
182
216
Changes the CSS media type of the page using [page.emulateMedia](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageemulatemediamediatype).
183
217
184
-
#### device
218
+
#####device
185
219
186
-
It generate the PDF using the [device](https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js) descriptor name settings, like `userAgent` and `viewport`.
220
+
It generate the PDF using the [device](#devices) descriptor name settings, like `userAgent` and `viewport`.
187
221
188
-
#### userAgent
222
+
#####userAgent
189
223
190
224
It will setup a custom user agent, using [page.setUserAgent](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetuseragentuseragent) method.
191
225
192
-
#### viewport
226
+
#####viewport
193
227
194
228
It will setup a custom viewport, using [page.setViewport](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetviewportviewport) method.
It returns an [tmpStream](https://github.com/Kikobeats/create-temp-file2#create-temp-file2), with `path` where the temporal file live and `cleanup`/`cleanupSync` methods for clean the temporal file.
218
252
219
-
The `options` provided are passed to [page.pdf](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions).
253
+
#### options
220
254
221
-
If you want to customize tmpStream settings, pass [opts.tmpOptions](https://github.com/Kikobeats/create-temp-file2#createtempfileoptions).
255
+
See [page.screenshot](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagescreenshotoptions).
256
+
257
+
Additionally, you can setup:
258
+
259
+
##### tmpOptions
260
+
261
+
See [createTempFile#options](https://github.com/Kikobeats/create-temp-file2#createtempfileoptions).
262
+
263
+
The `options` provided are passed to [page.pdf](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions).
222
264
223
265
Additionally, you can setup:
224
266
225
-
#### device
267
+
#####device
226
268
227
-
It generate the PDF using the [device](https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js) descriptor name settings, like `userAgent` and `viewport`.
269
+
It generate the PDF using the [device](#devices) descriptor name settings, like `userAgent` and `viewport`.
228
270
229
-
#### userAgent
271
+
#####userAgent
230
272
231
273
It will setup a custom user agent, using [page.setUserAgent](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetuseragentuseragent) method.
232
274
233
-
#### viewport
275
+
#####viewport
234
276
235
277
It will setup a custom viewport, using [page.setViewport](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetviewportviewport) method.
236
278
279
+
### .devices
280
+
281
+
List of all available devices preconfigured with `deviceName`, `viewport` and `userAgent` settings.
282
+
283
+
These devices are used for emulation purposes.
284
+
285
+
#### .getDevice(deviceName)
286
+
287
+
Get an specific device descriptor settings by descriptor name.
288
+
289
+
```js
290
+
constbrowserless=require('browserless')
291
+
292
+
browserless.getDevice('Macbook Pro 15')
293
+
294
+
// {
295
+
// name: 'Macbook Pro 15',
296
+
// userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X …',
297
+
// viewport: {
298
+
// width: 1440,
299
+
// height: 900,
300
+
// deviceScaleFactor: 1,
301
+
// isMobile: false,
302
+
// hasTouch: false,
303
+
// isLandscape: false
304
+
// }
305
+
// }
306
+
```
307
+
237
308
## Advanced
238
309
239
310
The following methods are exposed to be used in scenarios where you need more granuality control and less magic.
Internally the method performs a [.goto](#gotopage-options) operation and it will pass you the `page` and `reponse`.
280
351
281
-
### .page()
282
-
283
-
It returns a standalone [browser new page](https://github.com/GoogleChrome/puppeteer/blob/ddc59b247282774ccc53e3cc925efc30d4e25675/docs/api.md#browsernewpage).
284
-
285
-
```js
286
-
constbrowserless=require('browserless')
287
-
288
-
;(async () => {
289
-
constpage=awaitbrowserless.page()
290
-
})()
291
-
```
292
-
293
352
### .goto(page, options)
294
353
295
354
It performs a smart [page.goto](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options), blocking [ads trackers](https://npm.im/is-tracking-domain)) requests and other requests based on `resourceType`.
@@ -363,6 +422,23 @@ type: `object`
363
422
364
423
The settings to be passed to [page.goto](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagegotourl-options).
365
424
425
+
### .page()
426
+
427
+
It returns a standalone [browser new page](https://github.com/GoogleChrome/puppeteer/blob/ddc59b247282774ccc53e3cc925efc30d4e25675/docs/api.md#browsernewpage).
428
+
429
+
```js
430
+
constbrowserless=require('browserless')
431
+
432
+
;(async () => {
433
+
constpage=awaitbrowserless.page()
434
+
})()
435
+
```
436
+
437
+
## Benchmark
438
+
439
+

440
+
441
+
We included a tiny [benchmark](https://github.com/Kikobeats/browserless/tree/master/bench) utility for make easier testing multiple configuration settings.
366
442
367
443
## FAQ
368
444
@@ -380,10 +456,10 @@ In order to speed up the process, we block ads scripts by default because they a
380
456
381
457
Probably **browserless** was too smart and it blocked a request that you need.
382
458
383
-
You can active debug mode using `DEBUG=browserless` environment variable in order to see what is happening behind the code:
459
+
You can active debug mode using `DEBUG=browserless*` environment variable in order to see what is happening behind the code:
384
460
385
461
```
386
-
DEBUG=browserless node index.js
462
+
DEBUG=browserless* node index.js
387
463
```
388
464
389
465
Consider open an [issue](https://github.com/Kikobeats/browserless/issues/new) with the debug trace.
0 commit comments