This program is a python implement for CLI (command-line interface) web login in Southeast University (China). The whole script is based on httplib and json (I also add a fuction based on requests lib, which need extra package). The login and logout fuctions are based on portal.js (login and logout javascript) on w.seu.edu.cn.
本程序用于命令行内进行东南大学Web认证(认证上网或者登出)。程序基于python 的httplib and json库,通过https提交完成登录和退出。提交格式参照,w.seu.edu.cn的登录脚本portal.js。
You need to fill your username and password first, or include them in command, otherwise you need to input thme in std input (recommanded for public server).
使用前,请替换用户名和密码,或者在命令里面包含,否则,程序会在运行时要求你输入(比较适合在公用服务器上使用):
# replace with your username and password
USERNAME = 'your_username'
PASSWORD = 'your_password'
# or include them in command
python seu_weblogin.py login your_username your_password
# if not username or USERNAME are included, this program will require them from std input
python seu_weblogin.py login
username: your_username
password: your_password
Then just excute it with params.
运行参数如下:login-登录 logout-退出 status-查看在线状态 help-打印帮助
python seu_weblogin.py [login | logout | status | help]
-login:
Login by https. Print ip address.
-logout:
Logout by https.
-status:
Print login time, expire time, login location and login ip address. Time format 12:12:12(h:m:s).
-help:
Print usage.
Although other methods in linux is more easier, e.g. crul. Shell command for crul:
当然,其实linux用户可以用curl来登录和退出web认证(只是不能查看状态):
# replace with your username and password
curl -3 'https://w.seu.edu.cn/portal/login.php' -d 'username=your_username' -d 'password=your_password'
This program provide the possibility of network authentication (for SEU web login and logout) in python projects. Hoping it will help you.