fetch-webpage

A command that uses Chrome DevTools to collect a web page's text and images and save them in the project. Chrome DevTools is the browser's built-in set of inspection and automation tools.

In plain words
What is it for?
Use it to fetch a specified webpage, inspect its structure, take screenshots, and extract page content.
Why use it?
It provides a repeatable way to copy page content and visual references into a project.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/ant-intelligence/awesome-claude-code/fetch-webpage
Clone the repo
git clone --depth 1 https://github.com/Ant-Intelligence/awesome-claude-code

Made for: Claude Code.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,905 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01905
Opus 5 $0.00000 $0.00953
Sonnet 5 $0.00000 $0.00381
Haiku 4.5 $0.00000 $0.00191

Measured yesterday against content hash 01253976443b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

fetch-webpage scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -o public/images/[目录名]/[文章名]/[图片名] [图片URL]
Origin

This is a copy

100% identical to fetch-webpage — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.claude/commands/fetch-webpage.md · 219 lines

How it starts

The opening of the file, as written. The whole thing — 219 lines — stays where its author put it; the contents beside it link to each section on GitHub.

抓取网页内容并保存到项目

使用 Chrome DevTools MCP 抓取指定网页的内容,包括文本和图片,保存到本项目中。

参数

  • URL: $ARGUMENTS (必填,要抓取的网页地址)
  • 保存目录: 请在执行时询问用户

工具说明

工具 返回内容 用途
take_snapshot 基于 A11y 树的文本结构 + 元素 uid 快速了解页面结构、定位元素
take_screenshot PNG/JPEG 图片 视觉截图
evaluate_script 自定义 JS 返回值 提取 DOM、执行操作、分段加载大页面

关键特性take_snapshottake_screenshot 都支持 filePath 参数,可将内容保存到临时文件,然后使用 Read 工具分段加载。

执行步骤

1. 导航到目标页面

mcp__chrome-devtools__navigate_page({ type: "url", url: "目标URL" })

2. 检测页面大小

使用 evaluate_script 检测页面规模,决定是否需要分段提取:

mcp__chrome-devtools__evaluate_script({
  function: `() => ({
    totalHeight: document.documentElement.scrollHeight,
    textLength: document.body.innerText.length,
    sectionsCount: document.querySelectorAll('section, article, .content, main').length,
    imagesCount: document.querySelectorAll('img').length
  })`
})

判断标准:

  • 文本长度 < 10000 字符 → 小页面,直接提取
  • 文本长度 >= 10000 字符 → 大页面,分段提取或使用临时文件

3. 获取页面结构概览

方式 A:直接获取(小页面)
mcp__chrome-devtools__take_snapshot()

用于快速了解页面结构,但注意 snapshot 有 ~25000 令牌限制,超大页面可能报错。

方式 B:保存到临时文件后分段读取(大页面,推荐)
# 步骤 1:保存 snapshot 到临时文件
mcp__chrome-devtools__take_snapshot({ filePath: "/tmp/page-snapshot.txt" })

# 步骤 2:分段读取文件内容
Read(file_path: "/tmp/page-snapshot.txt", limit: 500)           # 前 500 行
Read(file_path: "/tmp/page-snapshot.txt", offset: 500, limit: 500)   # 500-1000 行
Read(file_path: "/tmp/page-snapshot.txt", offset: 1000, limit: 500)  # 1000-1500 行
# 继续按需读取...

临时文件方式的优势

  • 避免单次返回内容过大导致超时或截断
  • 可以按需读取特定部分,节省 token
  • 文件可复用,多次查阅无需重新抓取

4. 提取页面内容

小页面(< 10000 字符):直接提取
mcp__chrome-devtools__evaluate_script({
  function: `() => ({
    title: document.title,
    content: document.body.innerText,
    images: Array.from(document.querySelectorAll('img')).map(img => ({
      src: img.src,
      alt: img.alt
    }))
  })`
})
大页面(>= 10000 字符):多种分段策略

方案 A:保存到临时文件后分段读取(推荐)

// 步骤 1:将完整内容保存到临时文件
mcp__chrome-devtools__evaluate_script({
  function: `() => {
    const content = {
      title: document.title,
      url: window.location.href,
      content: document.body.innerText,
      html: document.body.innerHTML
    };
    return JSON.stringify(content, null, 2);
  }`
})
// 将返回的 JSON 内容写入临时文件
Write(file_path: "/tmp/page-content.json", content: "上面返回的内容")

// 步骤 2:分段读取
Read(file_path: "/tmp/page-content.json", limit: 300)
Read(file_path: "/tmp/page-content.json", offset: 300, limit: 300)
// 继续按需读取...

Read the full file on GitHub · 219 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 219 lines · 0 tokens per session scan A 01253976443b

Subscribe to this mod's changes

fetch-webpage is a command published in the GitHub repository Ant-Intelligence/awesome-claude-code (2 stars, last pushed 10d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,905 tokens. A static security scan graded it A with 1 finding (makes network calls). It is 100% identical to fetch-webpage, differing in 0 lines, and is treated as a copy.