Skip to content

High-level library for taking screenshot of websites based on headless chrome (puppeteer)

Notifications You must be signed in to change notification settings

AppliedSoul/headless-screenshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

headless-screenshot

npm package

Build Status Coverage Status Greenkeeper badge

headless-screenshot is a high-level on top of headless embedded chromium browser (puppeteer). It provides safe & easy to use interface for taking screenshot of websites.

Built with ❤️

Install

headless-screenshot depends on puppeteer, ensure its installed globally or locally before using this library.

npm i puppeteer headless-screenshot

Usage:

const HeadShot = require('headless-screenshot');
const Promise = require('bluebird');
const writeFile = Promise.promisify(require('fs').writeFile);

let hc = new HeadShot() // browser instance
hc.setup() // launches embedded chromium instance
  .then(() =>
    hc.getScreenshot('https://example.com')
    .then( res => {
      console.log(`resolvedUrl: ${res.resolvedUrl}, originalUrl: ${res.url}, isReachable: ${res.isReachable}`);
        writeFile('./example.png',res.data).then(() => console.log('file is written'));
    }).finally(() => hc.destroy())

For reference look at test cases.

About

High-level library for taking screenshot of websites based on headless chrome (puppeteer)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published