實戰範例
職缺追蹤器
排程追蹤新職缺,出現時即通知
監看一組徵才頁面,當符合篩選條件的新職位上線時,發通知到 Slack/email/Discord。同樣的模式也適用於房地產、市集刊登或任何「有新項目出現」的訊號。
Schema
{
"type": "object",
"properties": {
"title": { "type": "string", "description": "Job title" },
"department": { "type": "string" },
"location": { "type": "string", "description": "City or 'Remote'" },
"url": { "type": "string", "description": "Canonical job posting URL" },
"postedAt": { "type": "string", "description": "ISO-8601 timestamp if shown" }
},
"required": ["title", "url"]
}流程
- 排程(cron/GitHub Actions)把徵才頁 URL 提交到
/batch/extract - 完成時收到 Webhook
- 與上一輪做 diff —— 對新出現的
(url)發通知 - 通知前先用 title/location 關鍵字過濾
實作概述
import httpx, json, pathlib
API = "https://openapi.thunderbit.com/openapi/v1"
H = {"Authorization": "Bearer YOUR_API_KEY"}
STATE = pathlib.Path("seen.json")
careers = [
"https://example.com/careers",
"https://example.org/jobs",
]
job = httpx.post(f"{API}/batch/extract",
headers=H,
json={"urls": careers, "schema": SCHEMA}).json()
# Poll or webhook (see Batch Job Lifecycle guide)
seen = set(json.loads(STATE.read_text())) if STATE.exists() else set()
new = []
for r in job["data"]["results"]:
if r["status"] != "SUCCEEDED": continue
for item in r.get("data", []):
if item["url"] not in seen:
new.append(item)
seen.add(item["url"])
STATE.write_text(json.dumps(list(seen)))
notify(new) # your Slack / email / Discord hook小技巧
- 跨輪持久化
seenURL —— 沒做的話每輪都會把整份清單再通知一次 - 大膽過濾:
if "Engineer" in item["title"] and "Remote" in item["location"] - 跑 4–6 小時一次的節奏即可 —— 徵才頁不會每分鐘都變
相關
本食譜將補充 GitHub Actions workflow 範本 —— 敬請期待。