Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/appliedsoul/headless-screenshot

High-level library for taking screenshot of websites based on headless chrome (puppeteer)
https://github.com/appliedsoul/headless-screenshot

crawler headless-chromium javascript nodejs scrapper screenshot testing

Last synced: 26 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# headless-screenshot

[![npm package](https://nodei.co/npm/headless-screenshot.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/headless-screenshot/)

[![Build Status](https://travis-ci.org/AppliedSoul/headless-screenshot.svg?branch=master)](https://travis-ci.org/AppliedSoul/headless-screenshot) [![Coverage Status](https://coveralls.io/repos/github/AppliedSoul/headless-screenshot/badge.svg?branch=master)](https://coveralls.io/github/AppliedSoul/crawlmatic?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/AppliedSoul/headless-screenshot.svg)](https://greenkeeper.io/)

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 :heart:

## Install

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

```
npm i puppeteer headless-screenshot
```

Usage:

```javascript
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.