login to gw.bupt.edu.cn to access the Internet
Project description
BUPT Gateway Login
用于登录北京邮电大学校园网的命令行程序。跨平台,仅 Python 3。
可以从文件读取用户名和密码自动登录,或者通过参数指定用户名密码,也可以交互式输入用户名密码。
更新:
- 0.1.0:增加 check_net_account 函数,用于通过学校 VPN 登录页面检查上网账号是否正确。
已知问题:
- check_net_account 在校园网某些网络环境下不能工作。(在某些服务器上请求该页面,可以建立连接但服务器无响应)
安装
直接使用 pip 安装
pip install buptgw
如果有问题可以使用 pypi 源,且支持 IPv6,校园网电脑无需登录网络即可访问
pip install -i https://pypi.org/simple buptgw
如果你没有 root 权限,可以添加 --user 参数即
pip install buptgw --user 或
pip install -i https://pypi.org/simple buptgw --user
另外在某些比较旧版本系统上 pip 指向 pip2,所以需要使用 pip3 代替命令中的 pip
使用
登录 buptgw -i
退出 buptgw -o
保存用户名密码到文件(下次登录无需手动输入) buptgw -w
全部参数
Usage: buptgw -i|-o|-w [-c <config_file>] [-u <username>] [-p <password>]
-i login
-o logout
-w write username and password to config file
-c <config_path> config file path, optional, defualt is ~/.buptgw
-u <username>
-p <password>
参数 -i 代表登录 -o 代表退出,-w 把用户名和密码写入配置文件,这三个只能选择一个
-c 指定配置文件路径(存储用户名和密码),对 -i 和 -w 有效。如果不指定配置文件,默认为 ~/.buptgw。
-u 指定用户名,如果不指定,会从配置文件读取,如果读取失败则要求输入
-p 指定密码,如果不指定,则要求输入(如果用户名也没输入则一并从配置文件读取)
在 python 中调用
import buptgw
buptgw.login('2018xxxxxx', 'passwd') # 登录,xxx 处替换为正确的学号和密码
buptgw.logout() # 退出
buptgw.check_net_account('2018xxxxxx', 'passwd') # 检查该学号/密码是否匹配,如果匹配返回 True,不匹配返回 False
实现开机自动登录
window
windows 下编写 bat 文件(xxx 处替换为正确的学号和密码),例如保存为 network.bat (注意,不能保存为 buptgw.bat 这样会导致这个文件自己调用自己)
buptgw -i -u 2018xxxxxx -p xxxxx
然后把这个文件放到系统的启动目录下,一般来说,通过运行(快捷键是 win + R),输入 shell:startup 可以快速打开启动目录。
Linux
把登录命令写入 ~/.profile 中
作者博客 :https://es2q.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file buptgw-0.1.1.tar.gz.
File metadata
- Download URL: buptgw-0.1.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
669d5a272721a364208874d13556123b36c76047072652be25221bf0d591bf35
|
|
| MD5 |
a47e55ef94c87e5343998c14d6875df0
|
|
| BLAKE2b-256 |
7ad0802dda4a46b31f73e1f25fa0eec45fcfe4c24991ef03048443a5bb90fce8
|
File details
Details for the file buptgw-0.1.1-py3-none-any.whl.
File metadata
- Download URL: buptgw-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d54c18204104b143304b37a2a976d65d0f1d6014fe854169be98863d1df373ab
|
|
| MD5 |
8be7d2ed044f345ea69756d37fb5b4f9
|
|
| BLAKE2b-256 |
b4e4c7dc7d1e61c8863675bae6e7a455d14487485ae183b1d53db248455522c7
|