2.0.0-beta.6 • Published 4 months ago

webstack-screenshot v2.0.0-beta.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Introduction

Just some simple screenshot operations, if you have any needs, or want to participate in the development, we welcome you to PR

Quick Start

Vercel Free Deployment

Deploy with Vercel

Installation

npm install webstack-screenshot --save
const webstackScreenshot = require('webstack-screenshot')

webstackScreenshot({ url: 'https://example.com' }).then((buffer) => {
  console.log('buffer', buffer)
})

webstackScreenshot({ url: 'https://example.com', encoding: 'base64' }).then((base64) => {
  console.log('base64', base64)
})

ServerLess

You need to configure an environment variable name WEBSTACK_SCREENSHOT_SERVERLESS, and the value of the environment variable can be any value you want, e.g. true.

You may need to manually configure font files if the intercepted site contains text in other languages.

Configure the environment variable name WEBSTACK_SCREENSHOT_FONTS, the environment variable value can be a url or a path, multiple font files need to be split by ,. url address must be https://, path must be an absolute path.

e.g. /var/task/fonts/xxx.ttf,https://xxxxx/xxx/xxx.ttf.

module.exports = require('webstack-screenshot/dist/src/serverless')

Clone Warehouse

Clone remote repository start Website screenshot API

# Clone the repository and go to the WebStack-Screenshot directory
git clone https://github.com/Lete114/WebStack-Screenshot.git WebStack-Screenshot
cd WebStack-Screenshot

# Installing Dependencies
npm install

# Start service
npm run start

Properties

Request Method: GET | POST

PropertiesDefaultTypeDescription
urlStringThe URL of the requested website, if the domain name is entered it will be automatically spelled out as http://
typejpegStringThe image type, png, jpeg, webp
cache86400Int & Booleancache, default cache is 1 day, pass false to disable cache, pass number like:123 to cache 123 seconds
quality50IntImage quality between 0-100, ignored if the image type is png
viewport{width: 1080,height: 1920,isMobile: false}String | ViewportSet the screen window size
fullPagefalseBooleanCapture the full page
isMobilefalseBooleanIf or not it is mobile
await1000IntWait for the page to finish rendering
timeout30000IntScreenshot timeout, 0 means no limit (in milliseconds)
encodingbinaryStringImage encoding, binary, base64
clipStringClip the specified area, receive 4 units divided by English comma, x,y,width,height
waitUntilloadStringAt what time the screenshot is triggered, see another table below for details

waitUntil

PropertiesDescription
loadDone when the load event is fired
domcontentloadedDone when the DOMContentLoaded event is fired.
networkidle0When there are no website requests within 500ms
networkidle2When there are only 2 requests within 500ms
2.0.0-beta.6

4 months ago

2.0.0-beta.5

8 months ago

2.0.0-beta.4

8 months ago

2.0.0-beta.2

1 year ago

2.0.0-beta.3

1 year ago

2.0.0-beta.1

1 year ago

2.0.0-beta.0

1 year ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.9-beta.1

2 years ago

1.0.9-beta.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago