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

virtual-bit-network

v0.2.2

Published

Sign in on BIT WebVPN and convert URLs.

Downloads

5

Readme

Virtual BIT Network

BIT WebVPN 登录与转换。

> npm install YDX-2147483647/virtual-BIT-network  # from GitHub

程序界面

import VirtualBIT, { cli } from 'virtual-bit-network'

const proxy = new VirtualBIT({ username, password })
await proxy.sign_in(cli.display_captcha_then_ask_from_command_line({ width: '80%' }))

const response = await proxy.fetch('dzb.bit.edu.cn')

VirtualBIT.fetch()会自动转换 URL,添加 cookie。

CLI 命令行界面

> npm exec virtual-bit-network  # or `npm exec bit-webvpn`
? username: 1120○○○○○○
? password: [input is hidden]
✓ Signed in.
? Test which website? (eg. dzb.bit.edu.cn) dzb.bit.edu.cn
Got “北京理工大学党委办公室/行政办公室”.

由于网站规定,连续输错三次及以上,一般会需要验证码。

验证码图像被直接显示到终端

严重参考

可能遇到的问题

VirtualBIT.prototype.fetch只转换 URL,添加 cookie,除此以外什么也不做。——这无法解决全部问题。

具体案例:“数学实验中心”通知

前方玄学。

  • mec(数学实验中心)新闻公告的 API 会检查请求头的 Referer,必须在 mec.bit.edu.cn 下才行。

    encrypt_URL转换后的也可以,但 https://webvpn.bit.edu.cn 本身不行。)

  • 校内可直接访问。

  • 校外直接访问会炸。

  • (校外)若先用proxy.fetch访问任意网址,就能正常访问了。

    “任意网址”可以是 dzb(党政部)、百度、必应,甚至 mec 主站(http://mec.bit.edu.cn)!

  • 若把“访问任意网址”换成延时,仍无法正常访问。

下面这段程序会打印 mec 某则通知的标题。

需要先设置usernamepassword

import VirtualBIT, { cli, encrypt_URL } from './index.js'

const proxy = new VirtualBIT({ username, password })
await proxy.sign_in(cli.display_captcha_then_ask_from_command_line({ width: '80%' }))

// ↓玄学
await proxy.fetch('http://dzb.bit.edu.cn/')

await proxy.fetch('http://mec.bit.edu.cn/pcmd/ajax.php?vpn-12-o1-mec.bit.edu.cn&act=getmanage_nologin&w=新闻公告', {
  headers: {
    Referer: encrypt_URL('http://mec.bit.edu.cn'),
  },
}).then(r => r.json())
  // @ts-ignore
  .then(json => console.log(json.data.data[0].jmtitle))

// 输出示例:
// 2022年全国大学生数学建模竞赛报名通知(8月5日更新)