Auto-Heal
Auto-Heal
Section titled “Auto-Heal”Auto-Heal 是 HydraSkill 的自動容錯切換系統。當某個 IP 被封鎖、被禁、或觸發速率限制時,HydraSkill 會透明地切換到新的 IP —— 你的 agent 完全不需要處理 proxy 錯誤。
偵測機制如何運作
Section titled “偵測機制如何運作”HydraSkill 會監控回應中的封鎖訊號:
| 訊號 | 偵測方式 |
|---|---|
| HTTP 403 Forbidden | 直接封鎖 |
| HTTP 429 Too Many Requests | 速率限制 |
| CAPTCHA 頁面 | 內容分析 |
| Connection reset | 網路層封鎖 |
| 空回應 | 隱性封鎖 |
| 重新導向至封鎖頁面 | URL 樣式比對 |
Agent Request → Proxy → Target Site ↓ (blocked!) HydraSkill detects ↓ New IP assigned ↓ Request retried ↓Agent receives ← Success response你的 agent 程式碼維持精簡:
# proxy 錯誤不需要 try/exceptresponse = requests.get(url, proxies=proxy.to_dict())# 若第一個 IP 被封鎖,HydraSkill 已自動重試proxy = client.get_proxy( target="amazon.com", auto_heal=True, # 預設啟用 max_retries=3, # 最多重試 3 次 retry_delay_ms=500, # 重試之間的等待時間 rotate_on_block=True, # 被封鎖時取得新 IP)每個請求都有重試預算(預設:3 次)。如果所有重試都失敗,HydraSkill 會拋出 ProxyExhaustedError,讓你的 agent 可以處理這個邊界情況:
from hydraskill.exceptions import ProxyExhaustedError
try: response = requests.get(url, proxies=proxy.to_dict())except ProxyExhaustedError: # 所有重試皆失敗 —— 目標可能正在全面封鎖 log.warning(f"Could not reach {url} after 3 proxy rotations")在你的 dashboard 中追蹤 Auto-Heal 活動:
- Heal Rate —— 需要 IP 輪換的請求百分比
- Avg Recovery Time —— 切換 IP 所需的毫秒數
- Block Sources —— 哪些目標觸發最多封鎖
停用 Auto-Heal
Section titled “停用 Auto-Heal”用於除錯,或當你需要取得原始回應(包含封鎖)時:
proxy = client.get_proxy( target="example.com", auto_heal=False # 取得原始回應,包含 403)