Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashubham/webshot-factory
Web Screenshots at scale based on headless chrome
https://github.com/ashubham/webshot-factory
chrome-headless puppeteer screenshot webshot
Last synced: 4 days ago
JSON representation
Web Screenshots at scale based on headless chrome
- Host: GitHub
- URL: https://github.com/ashubham/webshot-factory
- Owner: ashubham
- Created: 2017-09-15T04:48:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T07:40:08.000Z (almost 2 years ago)
- Last Synced: 2024-11-07T13:16:05.328Z (5 days ago)
- Topics: chrome-headless, puppeteer, screenshot, webshot
- Language: TypeScript
- Homepage:
- Size: 415 KB
- Stars: 287
- Watchers: 8
- Forks: 9
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# webshot-factory
[![Build Status](https://travis-ci.org/ashubham/webshot-factory.svg?branch=master)](https://travis-ci.org/ashubham/webshot-factory)
[![npm version](https://badge.fury.io/js/webshot-factory.svg)](https://badge.fury.io/js/webshot-factory)screenshots at scale based on headless chrome.
## Basic Concept
- `Webshot-factory` creates a number of headless-chrome worker instances which take screenshots in round robin. Thus, can be horizontally scaled to provide good throughput.
- Includes a debug status page to monitor the worker instances.
- Can be used for batch report generation.
- Or to take a number of screenshots in general.
- Written in Typescript (types bundled).## Installation
```
npm i webshot-factory
```## Usage
```javascript
import * as shotFactory from 'webshot-factory';await shotFactory.init({
// Number of worker threads (chrome instances) to run.
// A shot is assigned to a worker in round robin.
concurrency: 10,// The callback method to be exposed on the window,
// which would be called by the application
// Shot will be taken when callback is called.
// This was 'callPhantom' in PhantomJS.
callbackName: '',// A cache warmer url,
// so that workers can cache the webpage scripts.
warmerUrl: 'http://google.com',
width: 1000, // shot width
height: 600, // shot height
timeout: 60000, // timeout (millis) to wait for shot.
webshotDebugPort: 3030 // Port where the status page is served.
// To use Puppeteer with a different version of Chrome or Chromium,
chromeExecutablePath: '/path/to/Chrome'
});// Once initialized, just call getShot and
// a shot will be scheduled on a worker
// chrome instance.
shotFactory.getShot('http://yahoo.com').then(buffer => {
// Do whatever with the buffer, can be used to email to recipients.
console.log(buffer);
// Or can be saved to a file.
// Using the `fs` module.
fs.createWriteStream('shot.png')
.write(buffer)
.end();
});
```## Status Page
`Webshot-factory` includes a status page to check the status of the running chrome instance workers.
Visit: `http://:/status`
Note: The default port is `3030`.
To check the status and debug any problems. The page looks like this: