JSPM

browserless

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

Simple & Functional Browser API.

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

Simple & Functional Browser API.

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

Install

$ npm install browserless --save

Usage

const browserless = require('browserless')

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

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.

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

It returns the full HTML extracted from the URL.

opts provided are passed to page.goto.

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

opts provided are passed to page.goto.

Additionally you can setup the CSS media providing opts.media (by default it will be 'screen'). This value will be passed to page.emulateMedia.

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

It takes an screenshot of the URL.

opts provided are passed to page.screenshot.

Additionally, you can setup the device providing opts.device and a valid deviceDescriptor.

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