Socket
Socket
Sign inDemoInstall

webstack-screenshot

Package Overview
Dependencies
121
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    webstack-screenshot

📸网站截图 API | Website Screenshot API


Version published
Weekly downloads
22
increased by450%
Maintainers
1
Created
Weekly downloads
 

Readme

Source
Language: English 中文

WebStack-Screenshot

Website Screenshot API

Version MIT License

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

Keywords

FAQs

Last updated on 09 Jan 2024

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