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 🙏

© 2026 – Pkg Stats / Ryan Hefner

chsi-verify

v1.0.3

Published

学信网学籍/学历/学位信息验证库

Downloads

42

Readme

chsi-verify

学信网学籍验证 TypeScript 库,使用 Puppeteer 自动提取学籍信息。

安装

npm install chsi-verify puppeteer

使用方法

方式一:使用便捷函数(推荐用于单次验证)

import { verifyChsi } from 'chsi-verify';

async function main() {
  const vcode = 'XXXXXXXXXXXXXXXX'; // 替换为实际的验证码
  const result = await verifyChsi(vcode);
  
  if (result.success) {
    console.log('验证成功!');
    console.log('学生信息:', result.data);
  } else {
    console.error('验证失败:', result.error);
  }
}

main();

方式二:使用类实例(推荐用于多次验证)

import { ChsiVerifier } from 'chsi-verify';

async function main() {
  const verifier = new ChsiVerifier({
    puppeteer: {
      headless: 'new',
      timeout: 30000
    }
  });
  
  try {
    // 第一次验证
    const result1 = await verifier.verify('VCODE1');
    console.log('第一次验证:', result1);
    
    // 第二次验证(复用浏览器)
    const result2 = await verifier.verify('VCODE2');
    console.log('第二次验证:', result2);
  } finally {
    // 记得销毁验证器,关闭浏览器
    await verifier.destroy();
  }
}

main();

方式三:自定义配置

import { verifyChsi } from 'chsi-verify';

async function main() {
  const result = await verifyChsi('XXXXXXXXXXXXXXXX', {
    baseUrl: 'https://www.chsi.com.cn',
    puppeteer: {
      headless: false, // 显示浏览器窗口(用于调试)
      timeout: 60000,
      args: [
        '--no-sandbox',
        '--disable-setuid-sandbox'
      ]
    }
  });
  
  if (result.success) {
    console.log('姓名:', result.data?.姓名);
    console.log('学校:', result.data?.学校名称);
    console.log('专业:', result.data?.专业);
    console.log('学籍状态:', result.data?.学籍状态);
  }
}

main();

API

类型定义

StudentInfo

学籍信息接口,包含以下字段:

  • 姓名: 学生姓名
  • 性别: 性别
  • 出生日期: 出生日期
  • 民族: 民族
  • 学校名称: 学校名称
  • 层次: 学历层次
  • 专业: 专业名称
  • 学制: 学制
  • 学历类别: 学历类别
  • 学习形式: 学习形式
  • 分院: 分院
  • 系所: 系所
  • 入学日期: 入学日期
  • 学籍状态: 学籍状态
  • 预计毕业日期: 预计毕业日期

VerifyResult

验证结果接口:

interface VerifyResult {
  success: boolean;      // 是否成功
  data?: StudentInfo;    // 学生信息(成功时返回)
  error?: string;        // 错误信息(失败时返回)
  timestamp: string;     // 时间戳
}

ChsiVerifyOptions

配置选项:

interface ChsiVerifyOptions {
  puppeteer?: PuppeteerOptions;  // Puppeteer 配置
  baseUrl?: string;              // 学信网基础 URL,默认为 https://www.chsi.com.cn
}

导出内容

  • ChsiVerifier: 验证器类
  • verifyChsi: 便捷验证函数
  • StudentInfo: 学籍信息类型
  • VerifyResult: 验证结果类型
  • ChsiVerifyOptions: 配置选项类型

运行示例

npm run example

开发

# 安装依赖
npm install

# 编译 TypeScript
npm run build

# 运行示例
npm run example

注意事项

  1. 需要安装 Chromium 或 Chrome 浏览器(Puppeteer 会自动下载)
  2. 在生产环境中建议使用 headless: 'new' 模式
  3. 如需调试,可设置 headless: false 查看浏览器操作过程
  4. 验证码需要从学信网获取,确保验证码有效且未过期
  5. 网络请求可能受学信网服务器响应速度影响,建议设置合理的超时时间

License

MIT