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 🙏

© 2025 – Pkg Stats / Ryan Hefner

top-wx-grab

v0.0.5

Published

top wx grab

Downloads

18

Readme

自动抓取微信公众号信息


模拟登录并且获取token

RobotGrab#login (username, pwd, code, callback)
    >1. err
    >2. result
        - msg
        - imgcode 如果错误码 -8,返回imgcode

| 参数 | 示意 | |-----------------|------------------| | username | 用户名 | | pwd | 密码 | | code | 验证码,可选仅当密码错误次数太多时,需要验证 | | callback | 可选回调函数,如果不传,返回promise |

获取微信号基本信息

RobotGrab#getAccountInfo(callback)
>1. err
>2. result
    - ret           错误吗
    - msg           错误消息
    - name          名称
    - originalId    原始ID
    - accountType   1.服务号 2.订阅号
    - isVerify      true认证 false未认证

| 参数 | 示意 | |-----------------|------------------| | callback | 可选回调,如果不传,返回promise|

开启开发者模式

GrabRobot#openDev(callback)
>1. err
>2. result
    - ret
    - msg

| 参数 | 示意 | |-----------------|------------------| | callback | 可选回调,如果不传,返回promise|

设置oauth2回调域名

GrabRobot#setOAuthDomain(domain, callback)
>1. err
>2. result
    - ret
    - msg
    - domain

| 参数 | 示意 | |-----------------|------------------| | domain| oauth授权成功后绑定的回调地址域名 |

配置微信公众号token以及接受消息地址

GrabRobot#receiveMessageConfig(validMsgToken, receiveMsgUrl, encrypt_mode, aeskey, callback)
>1. err
>2. result
    - ret
    - msg
    - callback_token
    - url
    - encodingKey
    - callback_encrypt_mode

| 参数 | 示意 | |-----------------|------------------| | validMsgToken | 开启开发者模式时,需要设置的token| | receiveMsgUrl | 开启开发者模式时,填写的接收消息地址| | encrypto_mode | 加密方式 0. 明文 ,| |aeskey |密阴| |callback | 可选回调,如果不传,使用promise形式 |

错误码详情

| ret | 错误消息(msg) | |--------|-----------------------| |"0" | "OK", | |"-1" |"系统错误 | |"-8" | "需要输入验证码" | | "-21" |"用户不存在", | | "-23 | "密码不正确", | |"-24" | "获取登录凭证失败", | |"-15" | "设置oauth2失败" | |"-302" | "token验证失败" | |"-18" | "缺少cookies" | |"-19" | "缺少token" |

使用 example

1. npm install top-wx-grab
2. 项目中使用,见下方:
    var robot = new GrabRobot();
    robot.login('username', 'password', '')
        .then(function(result) {
            if (result.ret === 0) {
                return robot.getAccountInfo()
            } else {
                return result;
            }
        })
        .catch(function(err){
          throw err;
        })
        .done(function(result) {
            if (result.ret !== 0 ) {
                //有错误了
                console.info(result.msg);
            } else {
                //获取成功
                console.info(result)
            }
        });
依赖

Q.js
request.js