Skip to main content

湘潭大学校园网登录 API

Project description

湘潭大学 校园网 API

安装

从 PyPI 安装:

pip install xtu-network

从 GitHub 安装:

pip install git+https://github.com/xtu-hit/xtu-network-python.git@main#egg=xtu-network

示例

简单代码示例

from xtu.network import XtuNetwork
from xtu.network import NoLoginError
from xtu.network import OnlineUserInfo

async def main():
    async with XtuNetwork(202400001111, "rsa_password") as xtu:
        print(await xtu.login())
        print(await xtu.checkOnline())

        print(await xtu.getErrorMsg())
        print(res := await xtu.getOnlineUserInfo())

        print(OnlineUserInfo.get_online_count_from_ball_info(res["ballInfo"]))

        print(await xtu.checkNetwork())

        try:
            print(await xtu.logout())
        except NoLoginError:
            pass

详见 example.py 用法

说明

  • XtuNetwork 类用于连接校园网。
  • getErrorMsg() 乍一看是获取错误信息,实际上什么也不返回,但是不调用此 API 的话 getOnlineUserInfo 就无法正确返回。
  • getOnlineUserInfo() 用于获取在线用户信息,返回一个字典。
  • checkNetwork() 用于检查网络状态,返回一个布尔值。
  • logout() 用于退出校园网,无返回值,如果尚未登录则抛出 NoLoginError 异常。

如何获得 RSA 加密后的密码?

使用 security.html 获取,或者 F12 查看校园网登录请求。

开源协议

本仓库使用 AGPL-3.0 协议,注意事项:

  1. 源代码共享义务:使用或修改此软件进行开发或提供网络服务时,必须提供完整的源代码。

  2. 网络应用条款:若通过网络向用户提供此程序的功能,必须确保用户能够获取到相应的源代码。

  3. 许可证继承:任何分发的修改版必须继续使用AGPL-3.0许可证,确保后续版本的开放性和共享要求。

  4. 修改版标识:任何分发的修改版本须在显著位置标明已修改,并附上具体修改的内容和日期。

  5. 专利权警示:使用此软件即表明你接受并遵循软件中规定的专利权限。

  6. 免责条款:软件按“现状”提供,不提供任何明示或暗示的保证。使用软件所产生的任何风险由用户自行承担。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xtu_network-0.0.22.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xtu_network-0.0.22-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file xtu_network-0.0.22.tar.gz.

File metadata

  • Download URL: xtu_network-0.0.22.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for xtu_network-0.0.22.tar.gz
Algorithm Hash digest
SHA256 4570a1923a2e6265cb1d139e1901b12ae76b4e5055286b0541f788e48c8cf9cb
MD5 41a7610cdbd0f54c903fe73ffb17e57a
BLAKE2b-256 3e86fb5f610bd76eb0527b50cbe6da9acad0d14c1a53ca82277ce8de7be474be

See more details on using hashes here.

File details

Details for the file xtu_network-0.0.22-py3-none-any.whl.

File metadata

  • Download URL: xtu_network-0.0.22-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for xtu_network-0.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 e95d7bbfd6f7d3f80f2de6b6e4027d77fc64cd85a74d3755f20fd2c55518786d
MD5 5defa395e49602a411f9cbf4d7a6e4c4
BLAKE2b-256 8adfa2e88d6b8f7f17faf52dfddf0531cb19ddc72866eaba67648efc78720aff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page