Giter Club home page Giter Club logo

capture-web's Introduction

capture-web

A tool, capture web page snapshot tobe png/gif.

NPM version

Effect

Goal

💻 Example — 👇 show-process

image/normal/2019-08-21/img-1566386341610-6930.gif

Result


Usage

install

# install
npm i @realign-zone/capture-web -S

Task

const CaptureWeb = require('@realign-zone/capture-web');

// configFilePath is:configFile's absolute path
CaptureWeb(`${configFilePath}`).then(() => {
    // do something after task done.
});

Config

configFile

module.exports = {
    // 整体配置项
    options: {
        imgDir = '', // 保存图片文件目录 | 绝对路径
        preName = '', // 图片文件名前缀 | 与后面的 name 拼接,构成完整 图片文件名称
        preUrl = '', // 页面路径前缀 | 与后面的 pagePath 拼接,构成完整 路径
    },
    // 所有需要捕获的页面
    pages: [
        {
            // 单个页面配置
            item: {
                name = '', // 当前页面名称
                pagePath = '', // 当前页面路径
                size = [1920, 1080], // 页面大小,若修改默认值:[Number, Number]
            },
            // 页面操作
            // 每个对象是一帧
            // 只有一个对象的话,就是 png,否则是 gif
            step: [
                {}, // 空对象,表示捕获页面截图
                // 其他的,参考非第一帧的话,参考 https://github.com/sindresorhus/capture-website#api
                {
                    beforeScreenshot: async (page /*, browser*/ ) => {
                        await page.type('#kw', 'github', {delay: 100});
                    },
                },
            ],
        },
    ],
};

Todo

  • Performance optimization
    • Too slow when capture gif
  • More config
  • Others

capture-web's People

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.