feat: 打卡记录拉取/缺卡统计工具(iEPMS token直连, 无需签名)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
"""Print full details of captured flows by index.
|
||||
|
||||
Usage:
|
||||
python tools/capture/show.py <index> [index ...] [--file flows.jsonl] [--max N]
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def fmt_body(body: dict | None, limit: int) -> str:
|
||||
if not body:
|
||||
return "<empty>"
|
||||
text = body.get("text")
|
||||
if text is None:
|
||||
return f"<binary {body['size']} bytes, b64>"
|
||||
try:
|
||||
text = json.dumps(json.loads(text), ensure_ascii=False, indent=2)
|
||||
except ValueError:
|
||||
pass
|
||||
return text if len(text) <= limit else text[:limit] + f"\n... <{len(text) - limit} more chars>"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("indexes", nargs="+", type=int)
|
||||
ap.add_argument("--file", default="data/captures/flows.jsonl")
|
||||
ap.add_argument("--max", type=int, default=4000)
|
||||
args = ap.parse_args()
|
||||
|
||||
lines = Path(args.file).read_text(encoding="utf-8").splitlines()
|
||||
for i in args.indexes:
|
||||
r = json.loads(lines[i])
|
||||
print(f"===== [{i}] {r['ts']} {r['method']} {r['url']}")
|
||||
print("--- request headers")
|
||||
for k, v in r["req_headers"]:
|
||||
print(f"{k}: {v}")
|
||||
print("--- request body")
|
||||
print(fmt_body(r["req_body"], args.max))
|
||||
print(f"--- response {r['status']} headers")
|
||||
for k, v in r["resp_headers"] or []:
|
||||
print(f"{k}: {v}")
|
||||
print("--- response body")
|
||||
print(fmt_body(r["resp_body"], args.max))
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user