Skip to main content

tail_fin_macromicro/
lib.rs

1//! MacroMicro 財經 M 平方 adapter — pure-HTTP client for `www.macromicro.me`.
2//!
3//! ## Auth model (three independent tokens — keep them straight)
4//!
5//! 1. **Cookies** (Netscape file): `cf_clearance` (Cloudflare bypass),
6//!    `PHPSESSID`, `mmu`, `mmt` (PHP session + member binding). The
7//!    `cf_clearance` token is short-lived (~1h, sometimes a few hours);
8//!    when it expires, re-export from a logged-in browser visit.
9//! 2. **`App.stk`** — 32-hex per-session token rendered in the page HTML at
10//!    `<p data-stk="…">` (footer). Sent as `Authorization: Bearer <stk>`
11//!    on `/charts/data/*` and `/api/view/chart/*`. The client lazily
12//!    fetches and caches it; `error #1165` triggers a transparent
13//!    refresh-and-retry inside the public methods, so callers do not
14//!    need to orchestrate manual recovery.
15//! 3. **JWT** from `GET /api/jwt` — member token (sub = member id, role
16//!    = `PRO`/`FREE`, exp +1h). Used for **other** member-gated APIs;
17//!    NOT the Bearer for chart data.
18//!
19//! Plus a custom `Docref` header echoing the page URL alongside
20//! `Referer` — both required on chart endpoints.
21//!
22//! No browser, no Cloudflare-clearance refresh logic. See [`http`] for
23//! the request-shape contract.
24
25pub mod http;
26pub mod parsing;
27pub mod types;
28
29pub use http::{normalize_ids, MacroMicroClient};
30pub use types::*;