A
返回 工具
工具2026/05/10 君澤智庫研究員 Bryan Chan3 分鐘閱讀

Web Fetch 與網頁抓取在 Agent 中的應用

在三層 Agent 框架中使用 Web Fetch / Puppeteer / fetch_url 獲取網頁內容的配置與場景指南。

Web Fetch 在三層中的角色

框架 用途 方式
Hermes Agent 背景資訊搜集 Python requests / fetch_url
OpenClaw 任務中抓取網頁 MCP Puppeteer / fetch_url
Claude Code 通過 OC 間接使用 不直接抓取

靜態頁面抓取(輕量)

# Python fetch(Hermes 背景搜集用)
import requests
from bs4 import BeautifulSoup

resp = requests.get("https://example.com/article")
soup = BeautifulSoup(resp.text, "html.parser")
text = soup.get_text()

動態頁面抓取(MCP Puppeteer)

需要 JavaScript 渲染的頁面用 Puppeteer MCP:

{
  "mcpServers": {
    "puppeteer": {
      "command": "npx",
      "args": ["@anthropic-ai/mcp-server-puppeteer"]
    }
  }
}

典型場景

場景 用什麼 例子
抓取 AI 新聞摘要 Hermes + requests 每日搜集
查詢 HKEX 公告 OpenClaw + Puppeteer /sdd 流程中
驗證外連結是否失效 腳本 + requests 建置時檢查

相關文章