关于 scraperapi-research-agent
ScraperAPI Research Agent 是用于端到端网络研究的 Agent 技能,面向需要整理带来源引用报告的研究任务。它用 ScraperAPI 搜索并抓取网页,再通过 Anthropic Files API 和 Messages API 让 Claude 汇总内容。
主要功能
- 01将研究问题拆分为搜索查询
- 02通过 Google Search 结构化端点发现来源
- 03去重并限制来源数量
- 04上传抓取内容并由 Claude 综合
- 05生成含行内引用的 Markdown 报告
适用场景
- 01整理特定主题的事实摘要
- 02比较不同方案并附来源引用
- 03基于近期网络资料生成研究报告
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ scraperapi/ scraperapi-skills --skill scraperapi-research-agent安装后在 Claude Code 中输入/scraperapi-research-agent确认已加载。
附带文件assets/report_template.mdscripts/research_agent.py
详细介绍
ScraperAPI 研究 Agent
端到端自主研究:ScraperAPI 查找并获取来源 → Anthropic Files API 将其摄取为带引用的文档 → Claude 综合生成报告。
运行:
# Install dependencies
pip install requests anthropic
# Set env vars
export SCRAPERAPI_API_KEY=your-key
export ANTHROPIC_API_KEY=your-key
# Run
python skills/scraperapi-research-agent/scripts/research_agent.py \
--question "What are the best practices for rate limiting in web APIs?" \
--max-sources 5 \
--output report.md
完整实现请参见 scripts/research_agent.py。
规划清单
开始研究前,请确定以下事项:
- 问题是否清晰 — 问题是否足够具体,能生成有用的搜索查询?“告诉我有关 AI 的信息”这类模糊问题会产生大量无关结果。更好的问题是:“对于特定领域的大模型,RAG 和微调各有哪些利弊?”
- 来源数量 — 需要多少个来源?事实摘要通常 3–5 个就足够;比较分析则需要 8–10 个。来源越多,ScraperAPI 积分消耗越多。
- 时效性 — 答案是否取决于近期事件?搜索查询将使用近期日期筛选条件。
- 积分预算 — 抓取每个来源约消耗 1 个积分(启用 JS 渲染时更多)。5 个来源总计约消耗 5–10 个积分。
- 停止条件 — 确定何时停止。默认停止条件为
--max-sources(5)。不要无限循环。
研究循环
1. PLAN
↓ Claude decomposes the question into 2–3 targeted search queries
2. DISCOVER
↓ ScraperAPI google/search structured endpoint → list of (url, title, snippet)
3. DEDUPLICATE
↓ Filter to top N unique URLs (default: 5), skipping PDFs and low-quality domains
4. FETCH
↓ ScraperAPI scrape each URL as markdown (output_format=markdown)
↓ Skip pages returning < 200 characters (blocked, error pages)
5. UPLOAD
↓ Upload each scraped page to Anthropic Files API as a text/plain artifact
↓ Store file_id for each source
6. SYNTHESIZE
↓ Claude (claude-opus-4-8, adaptive thinking) reads all document artifacts
↓ Returns structured report with inline citations [1], [2]...
7. CLEAN UP
↓ Delete uploaded file artifacts from Anthropic
↓ Write or print the final report
STOP when: max_sources reached, or all queries exhausted (whichever comes first).
停止条件
满足以下任一条件时,Agent 将停止:
- 达到
--max-sources(默认值:5)— 限制积分消耗 - 所有搜索查询均已用尽 — 没有更多 URL 可供探索
- 超出
--max-credits— ScraperAPI 积分使用量的硬性上限(可选)
如果没有停止条件,研究循环会持续获取内容,直到积分耗尽。
关键参数
| 标志 | 默认值 | 说明 |
|---|---|---|
--question | (必填) | 研究问题 |
--max-sources | 5 | 最多抓取的页面数(积分预算) |
--output | 标准输出 | 将报告写入文件 |
--country | us | ScraperAPI 国家/地区代码,用于按地理位置定位结果 |
--model | claude-opus-4-8 | 用于综合内容的 Anthropic 模型 |
输出格式
报告结构请参见 assets/report_template.md。
报告是 Markdown 文档,包含:
- 标题 — 根据研究问题生成
- 摘要 — 2–3 句话的执行摘要
- 研究发现 — 结构化章节,包含行内
[N]引用 - 来源 — 编号参考文献列表,包含 URL 和标题
积分成本估算
| 来源数 | 抓取积分 | Anthropic 令牌 | 总计估算 |
|---|---|---|---|
| 3 | ~3 | ~15K 输入 / ~2K 输出 | 低 |
| 5 | ~5 | ~25K 输入 / ~3K 输出 | 中 |
| 10 | ~10 | ~50K 输入 / ~5K 输出 | 较高 |
针对相同问题重复运行时,抓取内容会应用提示词缓存。
使用的 ScraperAPI 端点
- Google Search —
GET https://api.scraperapi.com/structured/google/search— 查找来源 URL - 抓取 —
GET https://api.scraperapi.com/?output_format=markdown— 获取页面内容
有关速率限制和积分成本,请参见 ScraperAPI 文档。
使用的 Anthropic API
- Files API(测试版)— 将抓取的页面上传为文档制品
- Messages API — Claude 综合生成带引用的报告
需要使用 ANTHROPIC_API_KEY,并且该密钥需有权访问 claude-opus-4-8 和 Files API 测试版。
评论
支持 Markdown