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, "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

说明

  • XtuNetwork 类是 xtu.network 模块的网络类,用于连接校园网。

  • NoLoginError 异常是 xtu.network 模块的异常类,用于表示尚未登录校园网。

  • getErrorMsg() 乍一看是获取错误信息,实际上什么也不返回,但是不调用此 API 的话 getOnlineUserInfo 就无法正确返回。

  • getOnlineUserInfo() 用于获取在线用户信息,返回一个字典。

  • checkNetwork() 用于检查网络状态,返回一个布尔值。

  • logout() 用于退出校园网,无返回值,如果尚未登录则抛出 NoLoginError 异常。

开源协议

本仓库使用 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.16.tar.gz (7.4 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.16-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xtu_network-0.0.16.tar.gz
  • Upload date:
  • Size: 7.4 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.16.tar.gz
Algorithm Hash digest
SHA256 4edce30072218eae971e6dfa4869c30351977060d4d5545381c2c85be59d4a8d
MD5 f8adaebb0218f57e388b5a122b800e26
BLAKE2b-256 26c2923907e52dd130367dc561a581aa0f652e36b9c81033ee9d08223418a944

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xtu_network-0.0.16-py3-none-any.whl
  • Upload date:
  • Size: 7.5 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.16-py3-none-any.whl
Algorithm Hash digest
SHA256 78b07b39567ff4c63455b5f7039b1c973c599502206a6e1516ec3d23df20a9dd
MD5 ea3727c3ac57b7a6be97b493e8ec94e0
BLAKE2b-256 c2c4ba07f70d8a4e6f70decf11427925e2694d326ff9cdd92270e86d3676c85f

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