JSPM

browserless

2.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15267
  • Score
    100M100P100Q128366F
  • 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()
  })

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])

opts provided are passed to page.goto.

Additionally, you can setup:

media

Providing a valid page.emulateMedia value. Default is 'screen'.

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

It takes an screenshot of the URL.

opts provided are passed to page.screenshot.

Additionally, you can setup:

device

Providing a valid deviceDescriptor object.

viewport

Providing a valid page.setViewport object.

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.

.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