Socket
Socket
Sign inDemoInstall

capture-all

Package Overview
Dependencies
1
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    capture-all

Flexible utility to get screenshots from Web pages


Version published
Weekly downloads
176
increased by17500%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

capture-all

Flexible utility to get screenshots from Web pages

Install

$ npm i capture-all
# or
$ yarn add capture-all

Example

const { captureAll } = require('capture-all')
const fs = require('fs')

captureAll([
  {
    // Web page URL which will be captured
    url: 'https://www.google.com/',

    // Selector for capturing element
    target: 'body',

    // Selectors to hide from capture
    hidden: ['#gb', '#fbar'],

    // Viewport size of a browser
    viewport: {
      width: 1024,
      height: 800
    }
  }
]).then(results => {
  results.forEach((result, i) => {
    fs.writeFileSync(`result-${i}.png`, result.image)
  })
})

API

captureAll(targets: CaptureTarget[], options?: CaptureOptions): Promise<CaptureResult[]>

Capture screenshots of Web pages which specified by targets and return an array of CaptureResult object including captured image buffer.

CaptureTarget may have the following properties:

  • url: Web page URL which will be captured (required)
  • target: a selector for capturing element
  • hidden: an array of selector to hide matched elements from captured image
  • viewport: viewport size of browser

CaptureOptions may have the following properties:

  • concurrency: a number of process which will be created for capture
  • puppeteer: an object passed to puppeteer.launch

CaptureResult has the following properties:

  • image: captured image buffer
  • url: captured Web page URL
  • target: a selector of captured element
  • hidden: an array of selector which is hidden from captured image
  • viewport: viewport size of browser

createCaptureStream(targets: CaptureTarget[], options?: CaptureOptions): ReadableStream<CaptureResult>

Similar to captureAll but returns readable stream of CaptureResult instead.

License

MIT

Keywords

FAQs

Last updated on 13 Jul 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc