Giter VIP home page Giter VIP logo

ke-snap's Introduction

环境依赖

本地运行

  • 启动

    npm run node-debug
  • 地址

    http://127.0.0.1:3000/api/shot?url=https%3A%2F%2Fwww.baidu.com%2F

线上部署

  • PM2
    npm run deploy

接口文档

  • 参数

    属性 类型 默认值 必填 说明
    src/source 调用方 标识
    callback JSONP 回调函数,不传为非 JSONP 请求
    cache 0 是否启用缓存,1是0否
    type data 返回类型,data文件url链接
    resheaders Response Headers,当 type == "data" 时生效
    url urls/url必有其一,待截图页面链接,GET请求需进行 urlencode
    name 截图名称,当 type == "data" 时生效
    c 待截图页面COOKIES,[{"name": "name", "value": "value", "domain": "domain"}],GET请求需进行 JSON.stringfy 和 urlencode
    urls urls/url必有其一,待截图页面链接,GET请求需进行 JSON.stringfy 和 urlencode
    - urls.url 待截图页面链接
    - urls.name 截图名称
    - urls.cookies 待截图页面COOKIES
    s 待截图页面元素,GET请求需进行 urlencode
    m 0 是否为移动端,1是0否,为移动端时,模拟器为 iPhone 6
    f 1 是否全屏截屏,1是0否,为1时全屏高度貌似为html元素的高度
    fs 获取全屏宽高页面元素,默认 document.body.scrollWidth/document.body.scrollHeight
    x 0 截屏左上角x坐标
    y 0 截屏左上角y坐标
    w 截屏宽度
    h 截屏高度
    t 500 预留页面渲染时间,单位为毫秒(ms)
    ts 0 截图当前时间戳
    scale 1 页面的缩放(可以认为是 dpr)
    actions 页面操作,GET请求需进行 JSON.stringfy 和 urlencode
    - actions.event 页面操作类型,支持类型:init(初始化)/click(点击)/back(返回)/wait(停留)
    - actions.selector 页面操作元素
    - actions.time 页面操作后,预留页面渲染时间,单位为毫秒(ms)
    - actions.name 页面操作后,截图名称
    - actions.snap 页面操作后,是否截图,1是0否,默认1
    - actions.html 页面操作后,是否保存页面,1是0否,默认0
  • 调用

    • GET or POST or JSONP
    • Content-Type 支持
      • application/json
      • application/x-www-form-urlencoded

注意事项

  • 全屏截屏
    • 全屏高度貌似为html元素的高度
    • 元素勿使用 height: 100% 之类的属性

TODO

  • 功能类

    • 调用数据存储 √
    • 调用数据统计 √
    • 图片上传S3
    • 过期本地图片
    • 支持截图名称 √
    • 支持RPC调用
    • 支持异步回调
    • 支持主动查询 √
    • 支持Websocket推送
  • 优化类

    • 截图失败重试 √
    • type=data占位图
    • 截小图拼大图 √
    • 优化异常处理 √
    • 批量并发处理
    • 截小图并发处理
    • 封装请求参数 √
    • 封装返回函数 √
    • 系统日志优化
  • 部署类

    • 生成Docker镜像

Why’s The Design

版本记录

CHANGELOG

License

MIT

Copyright(c) 2021 Lianjia, Inc. All Rights Reserved

ke-snap's People

Contributors

brightcells avatar

Watchers

James Cloos avatar  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.