| Crates.io | uestc-client |
| lib.rs | uestc-client |
| version | 0.3.0 |
| created_at | 2025-11-25 02:25:45.874698+00 |
| updated_at | 2026-01-13 07:41:49.58667+00 |
| description | A minimal reqwest client for UESTC. |
| homepage | |
| repository | https://github.com/kasuha07/uestc-client |
| max_upload_size | |
| id | 1949095 |
| size | 137,769 |
A minimal reqwest client for UESTC (University of Electronic Science and Technology of China).
这是一个电子科技大学(UESTC)的最小化 reqwest 客户端封装,用于模拟登录 UESTC 统一身份认证系统,并维持会话以便进行后续的 HTTP 请求。
reqwest's request builder for full flexibility.Add this to your Cargo.toml:
[dependencies]
uestc-client = "0.3.0"
tokio = { version = "1", features = ["full"] }
To use the blocking client, enable the blocking feature:
[dependencies]
uestc-client = { version = "0.2.1", features = ["blocking"] }
use uestc_client::UestcClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client with automatic cookie persistence
let client = UestcClient::new();
// Login - cookies are automatically saved and reused
// If valid cookies exist, login is skipped automatically
client.login("your_student_id", "your_password").await?;
// Now you can make authenticated requests
let resp = client.get("https://eportal.uestc.edu.cn/new/index.html")
.send()
.await?;
println!("Response status: {}", resp.status());
// Logout when done (clears cookies)
client.logout().await?;
Ok(())
}
use uestc_client::UestcClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client
let client = UestcClient::new();
// Login using WeChat QR code
// A QR code will be displayed in the terminal for you to scan
client.wechat_login().await?;
// Session is now active
let resp = client.get("https://eportal.uestc.edu.cn/new/index.html")
.send()
.await?;
println!("Response status: {}", resp.status());
Ok(())
}
You can also specify a custom cookie file path:
let client = UestcClient::with_cookie_file("my_cookies.json");
client.login("your_student_id", "your_password").await?;
Enable the blocking feature in your Cargo.toml.
use uestc_client::UestcBlockingClient;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = UestcBlockingClient::new();
// Login - cookies are automatically managed
client.login("your_student_id", "your_password")?;
// Authenticated request
let resp = client.get("https://eportal.uestc.edu.cn/new/index.html")
.send()?;
println!("Response status: {}", resp.status());
// Logout
client.logout()?;
Ok(())
}
use uestc_client::UestcBlockingClient;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = UestcBlockingClient::new();
// Login using WeChat QR code
// A QR code will be displayed in the terminal for you to scan
client.wechat_login()?;
// Session is now active
let resp = client.get("https://eportal.uestc.edu.cn/new/index.html")
.send()?;
println!("Response status: {}", resp.status());
Ok(())
}
The repository includes working examples in the examples/ directory:
async_wechat_login.rs - Async WeChat QR code loginblocking_wechat_login.rs - Blocking WeChat QR code loginRun them with:
# Async WeChat login (default features)
cargo run --example async_wechat_login
# Blocking WeChat login
cargo run --no-default-features --features blocking --example blocking_wechat_login
This project is licensed under the MIT License.