npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

take-webpage-screenshot

v1.0.6

Published

Downloads

8

Readme

网页截图lib

网页截图任务参数

{
  "pageUrl": "https://google.com", //需要截图的目标页面完整URL,
  "timeToPageLoad": 3000, //非必填, 在截图前的等待时间单位毫秒,用于等待页面渲染完毕。默认值3000
  "cookies": [ //非必填, 需要设置的cookie列表,例如需要进行鉴权登录的页面,设置登录cookie
    { 
      "name": 'access-token',
      "value": "",
      "domain": "test.com",
      "secure": true, //非必填
      "path": "/", //非必填
      "sameSite": "None" //非必填
    }
  ],
  "mode": "elementBase", // 截图模式:elementBase(基于元素), viewportBase(基于可视区域)
  "screenshotSetting": {  //非必填,截图设置, 部分参数可参照:https://pptr.dev/#?product=Puppeteer&version=v11.0.0&show=api-pagescreenshotoptions
    "type": "png",  // 默认值: jpeg
    "quality": 100, // 默认值:100
    "omitBackground": false, // 默认值: false
    "encoding": "binary", // 默认值:binary
  },
  "modeSetting": {
    "elementBase": { // 只需要设定需要截取的元素
      "elementSelector": "#element-id",
      "viewportWidth": 200, // 默认值:1024
      "viewportHeight": 400, // 默认值:800 
      "offset": { //非必填 截取元素内区域,通过指定,区域四边对应元素边界的偏移量设置
        "top": 10, // 默认值:0
        "left": 10, // 默认值:0
        "right": 10, // 默认值:0
        "bottom": 10 // 默认值:0
      }
    },
    "viewportBase": { // custom 模式, 通过定义视窗大小,和要截取的区域,进行截图
      "viewportWidth": 200,// 默认值:1024
      "viewportHeight": 400, // 默认值:800
      "fullPage": false, // 是否截取viewport以外的scroll区域, 默认值:false
      "clip": { //非必填 截图区域
        "x": 10,
        "y": 10,
        "width": 200,
        "height": 200
      }
    }
  }
}

相关依赖

  1. ts类型定义转json-schema: https://github.com/YousefED/typescript-json-schema
  2. 获取json-schema中默认值: https://www.npmjs.com/package/json-schema-defaults
  3. Puppeteer 浏览器node库: https://pptr.dev