Metadata-Version: 2.4
Name: buptmw
Version: 0.3.1
Summary: Help BUPT students access school system with python.
Project-URL: Homepage, https://github.com/ZeroCore-Zero/BUPT_Middleware
Author-email: ZeroCore <esetting@hotmail.com>
License-Expression: GPL-3.0-or-later
License-File: LICENSE
Keywords: BUPT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.11
Requires-Dist: beautifulsoup4>=4.13.5
Requires-Dist: buptapis>=0.2.1
Requires-Dist: httpx>=0.27.0
Requires-Dist: lxml>=6.0.2
Requires-Dist: pydantic>=2.13.4
Description-Content-Type: text/markdown

# BUPT_Middleware

[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ZeroCore-Zero/BUPT_Middleware)

This project aims to help BUPT students simply access school systems with python, without authentication process manually.

## Supported

- Access [CAS](https://auth.bupt.edu.cn/authserver/login)
  - Access [UC](https://uc.bupt.edu.cn/#/user/pc/index)
  - Access [UCloud](https://ucloud.bupt.edu.cn/)
  - Access [Electric](https://app.bupt.edu.cn/buptdf/wap/default/chong/)
- Access [Academic](https://jwgl.bupt.edu.cn/jsxsd/)

## Install

``` bash
pip install buptmw
```

## Usage

> [!IMPORTANT]
>
> Always use `get_client()` to obtain the client before making requests. It will automatically check and refresh the session if it has expired.

### Normal Using

Follow the **Credential**->**Auth**->**App** layout chain, and call `get_client()` to get a verified `httpx.Client`, which you can use to make requests. Any tiresome authentication can be omitted for you.

``` python
from buptmw import CASCredential, CASAuth, UCloud

cred = CASCredential(username="yourUsername", password="yourPassword")
auth = CASAuth(cred)
app = UCloud(auth)

client = app.get_client()
response = client.get("https://someurl")
# do something with response
```

### Quick Using

Directly pass credentials to apps.

``` python
from buptmw import CASAuth, UCloud
cred = CASCredential(username="yourUsername", password="yourPassword")
app = UCloud(cred)
# or directly use dict
app = UCloud({"username": "yourUsername", "password": "yourPassword"})

client = app.get_client()
response = client.get("https://someurl")
# do something with response
```
