AgentSkillsCN

fetch-urls

将 URL 转换为 Markdown 格式,从网页中提取单一锚点章节,或按层级列出页面的所有锚点。支持大型页面的分页功能。当您需要读取某个 URL、提取页面的特定部分,或了解页面包含哪些章节时,这套工具将助您一臂之力。

SKILL.md
--- frontmatter
name: fetch-urls
description: Fetch a URL as markdown, extract a single anchor section from a web page, or list all page anchors with hierarchy. Supports pagination for large pages. Use when you need to read a URL, fetch a specific section of a page, or discover what sections a page has.
allowed_tools: ["Bash"]

Fetch URLs

Fetch web content via a Python script. Three modes: full page, single anchor section, or anchor discovery.

Commands

Full page as markdown:

bash
uv run "$SKILLS_DIR/scripts/fetch_anchor.py" "<url>"

Single anchor section (URL must contain #fragment):

bash
uv run "$SKILLS_DIR/scripts/fetch_anchor.py" "<url>#<anchor>" --only-current-anchor

List all anchors (shows heading hierarchy):

bash
uv run "$SKILLS_DIR/scripts/fetch_anchor.py" "<url>" --list-anchors

Pagination (for large pages or sections):

bash
uv run "$SKILLS_DIR/scripts/fetch_anchor.py" "<url>" --max-length 5000 --start-index 5000

Raw HTML (combine with any mode above):

bash
uv run "$SKILLS_DIR/scripts/fetch_anchor.py" "<url>" --raw

Flags

FlagDescription
--only-current-anchorReturn only the section matching the URL's #fragment
--rawOutput raw HTML instead of markdown
--max-length NLimit output to N characters (enables pagination)
--start-index NStart at character N (use with --max-length for next page)
--list-anchorsList all anchors, grouped by heading hierarchy

Workflow

  1. Full page: pass the URL. HTML is simplified via readability, then converted to markdown. Non-HTML (JSON, plain text) is returned as-is.
  2. Anchor mode: if the user provides a URL with #fragment, pass it with --only-current-anchor. The fragment is extracted from the URL automatically. Captures the full section including all sub-headings at lower levels.
  3. Discovery: if the user asks for a section but the anchor ID is unknown, use --list-anchors first. Output shows heading hierarchy with indentation and levels (h1-h6) so you can pick the right anchor.
  4. Pagination: for large content, use --max-length. The script appends a truncation notice with the next --start-index value.

Requirements

Requires uv on the system. The script uses PEP 723 inline metadata — uv run resolves and caches dependencies automatically (no venv needed).