Communitygithub.com

baronguyen001/プロキシローテーター

ラウンドロビン選択、障害追跡、クールダウン機能を備えたHTTP/SOCKSプロキシプールをローテーションします。プロキシリストは環境変数経由で提供します。

プロキシローテーター とは?

このスキルは、スクレイピングや自動化タスクにおいて、複数のプロキシにリクエストを分散し、IP禁止を回避したり、応答しなくなったプロキシを自動的に除外するためのプロキシローテーターです。Claude Code、Cursor、CodexなどのAIエージェントが、与えられたプロキシリストをラウンドロビンで管理し、失敗回数が閾値を超えたプロキシをクールダウンウィンドウで一時的に隔離した後、再試行します。`ProxyRotator` クラスが環境変数からプロキシを読み込み、`get()` で次の健全なプロキシを取得し、`report()` でリクエスト結果をフィードバックすることで自己修復的に動作します。主なユースケースは、大規模なスクレイピング、APIのレート制限回避、プロキシヘルスチェックの自動化です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/baronguyen001/ai-automation-skills/tree/HEAD/skills/proxy-rotator

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

プロキシローテーター は何をしますか?

このスキルは、スクレイパーが複数のプロキシにリクエストを分散し、動作しなくなったプロキシへの過剰な負荷を防ぐために使用します。ローテーターは次の健全なプロキシを割り当て、失敗回数をカウントし、プロキシが頻繁に失敗した場合は一定のクールダウンウィンドウの間隔離し、その後再試行します。プロキシリストはユーザーが自分で用意する必要があり、スキル自体には含まれていません。

呼び出すべきタイミング

  • ユーザーが「プロキシをローテーションして」「プロキシ間でリクエストを分散して」「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.

関連スキル