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.23.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.23-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xtu_network-0.0.23.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.23.tar.gz
Algorithm Hash digest
SHA256 5124cfc98b5c553ec7c2940acf5ff9b80c49cc27e89724726d0c54156c0ed590
MD5 7294f89d1317ebbd591ed4f7a301c601
BLAKE2b-256 ba0281beadab66bab79c220c008b2eaa0feb3ff9f43ef82db7b9bcbbdffb73b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xtu_network-0.0.23-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.23-py3-none-any.whl
Algorithm Hash digest
SHA256 a10a4a411504145cefb034c7fb6e891d38390f6501c35c828430159146738755
MD5 9023f5854737bdc41f3c5b9449317459
BLAKE2b-256 bdf93e996b752cd83b5c0e3b05a906b91efb5d07fa9770c71d3e89f36f8d78fa

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