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.17.tar.gz (7.5 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.17-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xtu_network-0.0.17.tar.gz
  • Upload date:
  • Size: 7.5 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.17.tar.gz
Algorithm Hash digest
SHA256 0e6518be2b8b93fa86303030bbe5a665c787efd49c1cc7717dae77d18908b428
MD5 20499ec0bb677b92abc2c681881cd8fd
BLAKE2b-256 d91d105c35a1f752177f161d22fcfe64d92a1c2af319699ec0ea57b08e8a3f98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xtu_network-0.0.17-py3-none-any.whl
  • Upload date:
  • Size: 7.6 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.17-py3-none-any.whl
Algorithm Hash digest
SHA256 09b43b5e92318e398e0ba4d30ebc501e87d46e077ccf3ca9551d87c90be19d55
MD5 9f3d4628535bd95598e006ce9c7ff040
BLAKE2b-256 5d5a9fff4621debd100e791a92c81a73c74e8683cf08bd549519b11c9eb56ca5

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