Communitygithub.com

baronguyen001/ai-automation-skills

透過循環輪詢、失敗追蹤與冷卻機制輪換 HTTP/SOCKS 代理池,自動隔離故障代理並於稍後重試。需自行透過環境變數提供代理清單(不內建任何代理)。用於輪換代理、分散請求、避免 IP 封鎖、透過不同代理重試,或進行代理健康檢查。

ai-automation-skills 是什麼?

這個技能提供一個專業的 Proxy Rotator(代理輪換器),專為需要大量對外請求的爬蟲或自動化腳本設計。其核心功能是從使用者提供的代理池中,以循環輪詢(round-robin)方式分配健康代理,並內建失敗追蹤機制。當某個代理連續失敗次數超過設定門檻,該代理會進入冷卻區(cooldown),暫時不再被使用,待冷卻時間過後才會再次加入輪換,從而避免反覆使用已故障的代理。此技能支援所有類型的 HTTP/SOCKS 代理,並可搭配 Cursor、Claude Code、Codex 等 AI 編碼工具使用。使用者僅需透過環境變數 `PROXY_POOL` 提供代理清單,即可在 Python 程式中呼叫 `ProxyRotator` 類別,執行 `get()` 取得下一個健康代理,並在請求完成後呼叫 `report()` 回報結果,讓代理池自動自我修復。此外,也建議在大量請求前執行 `health_check` 預先隔離故障代理。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/baronguyen001/ai-automation-skills/tree/HEAD/skills/proxy-rotator

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

代理輪換器

當爬蟲需要將請求分散到多個代理,並避免持續使用已故障的代理時,請使用此技能。輪換器會分配下一個健康代理,記錄失敗次數,並在代理失敗過多次後將其放入冷卻區,待冷卻時間結束後再給予一次機會。您需要自行提供代理清單;本技能不會內建任何代理。

何時呼叫

  • 使用者說:「輪換代理」、「將請求分散到多個代理」、「不要再被 IP 封鎖了」、「透過另一個代理重試」。
  • 對話中的程式碼需要發出大量對外請求,並需將請求分散到代理池中。

何時不應呼叫

  • 單一連線即可滿足需求,或目標網站明確允許您目前的請求量——輪換代理只會增加不必要的複雜性。
  • 意圖規避明確的封鎖或濫用服務;請確保使用方式符合目標服務的使用條款。

具體範例

使用者輸入:

我有 5 個代理。以循環輪詢方式使用它們,並跳過任何開始失敗的代理。

輸出:

import requests
from rotator import ProxyRotator

rot = ProxyRotator.from_env()        # PROXY_POOL="http://h1:8080,socks5://h2:1080,..."
for url in urls:
    p = rot.get()                    # 下一個健康代理
    try:
        r = requests.get(url, proxies=p.as_dict(), timeout=15)
        rot.report(p, ok=r.ok)       # 將結果回饋給代理池,讓其自動修復
    except Exception:
        rot.report(p, ok=False)      # 失敗次數過多 → 代理將被放入冷卻區

應用的模式

  1. 從環境變數或已加入 .gitignore 的檔案載入代理清單——切勿提交真實的代理 URL 或憑證。
  2. 每次請求後務必呼叫 report(proxy, ok=...),使失敗代理自動被隔離。
  3. 根據目標調整 max_fails 和 cooldown 參數;較短的冷卻時間可恢復不穩定的代理,較長的冷卻時間則會淘汰品質較差的代理。
  4. 在進行大量批次請求前,先執行 health_check 以預先隔離已故障的代理。
  5. 妥善處理「無健康代理可用」的錯誤——採取退避重試策略,而非直接讓程式崩潰。

參考檔案:assets/rotator.py。

來源

本技能源自作者在多個自動化專案中的實際生產經驗提煉而成。v1.0.0。 另見:[[playwright-login-session]]、[[pipeline-orchestrator]]、[[cron-dispatch]]。

→ 使用 Trawlkit 建置完整的可執行機器人。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

baronguyen001/ai-automation-skills

Schedule any script to run on a recurring schedule on Windows (Task Scheduler) or Linux (cron) - register, list, and remove jobs from one command, with logging to a file and a guard against overlapping runs. Use for schedule a script, run nightly, set up a cron job, windows task scheduler, or run on a timer.

baronguyen001/ai-automation-skills

Turn a run's list of result dicts into a schema'd CSV and a Markdown table from one column spec - declare columns once, emit both, with stable ordering and safe escaping, stdlib only, no pandas. Use when the user asks to write results to CSV, export a report, make a markdown summary table, or save a run's output as a spreadsheet.

baronguyen001/ai-automation-skills

Strip HTML to clean plain text with the standard library only (no BeautifulSoup/lxml): drops script/style, turns block tags into line breaks, and collapses whitespace. Use when the user wants readable text from an HTML page/email, to clean scraped HTML before sending it to an LLM, or to build a text index from web content.

baronguyen001/ai-automation-skills

Persist records between scheduled runs as append-only JSON Lines (one object per line) with streaming reads and optional key-based dedup, stdlib only. Use when the user wants to log run results to JSONL, append events to a file, dedup records by id across runs, or keep a simple durable history without a database.

baronguyen001/ai-automation-skills

Extract text and simple table-like rows from a PDF for downstream AI without OCR binaries. Use when the user asks to read a PDF, turn a PDF into text, pull simple tables from statements/reports, or feed PDF content into an LLM pipeline.

baronguyen001/ai-automation-skills

Parse an RSS 2.0 or Atom feed into normalized item dicts (title, link, id, published, summary) with the standard library only - no feedparser. Use when the user asks to read an RSS/Atom feed, poll a blog/news feed, extract feed entries, or watch a site that publishes a feed.

baronguyen001/ai-automation-skills

Upload and download run artifacts from S3-compatible storage with BYO bucket and credentials from env. Use when the user asks to store scraper output, archive reports, publish artifacts to object storage, fetch a prior run file, or use MinIO/R2/Spaces/S3 without hardcoding credentials.

baronguyen001/ai-automation-skills

Draft a short-form TikTok/Reels/Shorts or long-form video script from a topic and creator persona file - hook variants, beat-structured body, CTA, b-roll cues, caption overlays, and [STORY]/[NUMBER] slots so the model never fabricates personal facts. Use for write a video script, tiktok script, youtube script, or /shortform-script.

baronguyen001/ai-automation-skills

Give scheduled scripts memory between runs with one SQLite file - a seen-set for dedup, a key/value cursor to resume where you left off, and order-preserving new-item filtering. Use for dedup across runs, don't re-alert the same item, remember the last id, resume a scraper, or persist state between cron runs.

相關技能