JSPM

browserless

2.3.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15469
  • Score
    100M100P100Q128241F
  • License MIT

Chrome Headless API made easy

Package Exports

  • browserless

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (browserless) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

browserless

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status Donate

Chrome Headless API made easy

This module is an API simplification over Chrome Headless API for do common actions, like take an screenshot:

const browserless = require('browserless')()

browserless
  .screenshot('http://example.com', { device: 'iPhone 6' })
  .then(tmpStream => {
    console.log(`your screenshot at ${tmpStream.path}`)
    tmpStream.cleanupSync()
  })

See more at examples.

Install

$ npm install browserless --save

API

All methods needs a valid url as required first argument. The second argument will be opts for configure specific method settings.

All methods expose an universal promise/callback interface: If you provide a function as last argument, then the output of the method will be following callback style. Otherwise, it returns an promise.

.constructor([opts])

Setup puppeter.launch instance.

.html(url, [opts], [cb])

It returns the full HTML extracted from the URL.

opts provided are passed to page.goto.

.pdf(url, [opts], [cb])

It generates the PDF version of a website behing an URL.

opts provided are passed to page.pdf.

It returns an tmpStream, with path where the temporal file live and cleanup/cleanupSync methods for clean the temporal file.

If you want to customize where tmpStream live, pass opts.tmpOptions.

Additionally, you can setup:

media

Changes the CSS media type of the page using page.emulateMedia.

device

Providing a valid deviceDescriptor object.

The device will be used to recover and setup userAgent and viewport.

userAgent

It will setup User Agent using page.setUserAgent method.

viewport

Providing a valid page.setViewport object.

.screenshot(url, [opts], [cb])

It takes an screenshot of the URL.

opts provided are passed to page.screenshot.

It returns an tmpStream, with path where the temporal file live and cleanup/cleanupSync methods for clean the temporal file.

If you want to customize where tmpStream live, pass opts.tmpOptions.

Additionally, you can setup:

device

Providing a valid deviceDescriptor object.

The device will be used to recover and setup userAgent and viewport.

userAgent

It will setup User Agent using page.setUserAgent method.

viewport

Providing a valid page.setViewport object.

.text(url, [options], [cb])

It returns the text extracted from the URL.

opts provided are passed to page.goto.

License

browserless © Kiko Beats, Released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · Twitter @kikobeats