Communitygithub.com

baronguyen001/ai-automation-skills

通过轮询选择、故障跟踪和冷却机制轮换 HTTP/SOCKS 代理池,自动禁用失效代理并在冷却后重试。需自行通过环境变量提供代理列表,不内置任何代理。

ai-automation-skills 是什么?

该技能实现了一个智能代理轮换器,用于在爬虫或其他自动化工具中分散请求到多个 HTTP/SOCKS 代理。它采用轮询(Round-Robin)算法分配下一个健康代理,并跟踪每个代理的失败次数;当某个代理失败过多时,会被暂时禁用(冷却)一段时间,冷却期过后再重新尝试使用。用户需通过环境变量 `PROXY_POOL` 提供代理列表(例如 `http://h1:8080,socks5://h2:1080`),技能本身不提交任何代理。支持平台包括普通 Python 环境以及任何可以调用 Python 脚本的 AI Agent(如 Claude Code、Cursor 等)。使用方式直观:调用 `rot.get()` 获取下一个代理,发起请求后调用 `rot.report(proxy, ok=...)` 反馈结果,系统自动根据失败次数和冷却配置进行自我修复。同时提供 `health_check` 方法用于在批量请求前预检代理健康状态。该技能源自作者自动化项目的生产实践,适合需要避免 IP 封禁、提高请求成功率的场景。

兼容平台~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. 从环境变量或已忽略的 git 文件中加载代理——切勿提交真实的代理 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.

相关技能