360 Secure SkillHub
360 安全技能中心

Sitemap Generator

通过 BFS 同域链接发现抓取网站,或扫描本地 HTML/HTM/MD/PHP 文件,生成符合 sitemaps.org 规范的 sitemap.xml;支持 XML、文本、JSON 输出,可识别 lastmod 日期并附带生成 robots.txt,仅依赖 Python 3 标准库。

charlie-morrison
charlie-morrison
热度 35.90
最近更新 2026-05-11 17:47:01
分类:营销依赖:代码执行 / 读写文件应用场景:自动化脚本 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add cm-sitemap-generator
Metadata
name
sitemap-generator
description
Generate XML sitemaps by crawling a website or scanning local files. Auto-discovers pages via link extraction. Supports local HTML/MD file scanning with lastmod dates. Generates robots.txt with sitemap reference. Use when asked to create a sitemap, generate sitemap.xml, crawl a site for pages, create robots.txt, or prepare a site for SEO. Triggers on "sitemap", "sitemap.xml", "crawl site", "site map", "robots.txt", "SEO sitemap".

Sitemap Generator

Generate XML sitemaps by crawling a live website or scanning local HTML files.

Crawl a Website

python3 scripts/sitemap_gen.py https://example.com

Scan Local Files

python3 scripts/sitemap_gen.py --local ./public --base-url https://example.com

Save to File

# Save sitemap.xml
python3 scripts/sitemap_gen.py https://example.com --output sitemap.xml

# Save sitemap.xml + robots.txt
python3 scripts/sitemap_gen.py https://example.com --output sitemap.xml --robots

Output Formats

# XML (default — valid sitemap.xml)
python3 scripts/sitemap_gen.py https://example.com

# Text (human-readable summary + XML)
python3 scripts/sitemap_gen.py https://example.com --format text

# JSON (pages list + XML string)
python3 scripts/sitemap_gen.py https://example.com --format json

Options

Flag Default Description
--max-pages 500 Maximum pages to crawl
--timeout 10 Request timeout in seconds
--output / -o stdout Save sitemap.xml to file
--robots off Also generate robots.txt
--local off Scan local directory instead of crawling
--base-url — Base URL for local mode (required)
--verbose / -v off Show crawl progress

Features

  • Crawl mode: BFS link discovery, same-domain only, deduplication
  • Local mode: Scan HTML/HTM/MD/PHP files, auto-detect lastmod from file mtime
  • Smart filtering: Skips images, CSS, JS, PDFs, archives, media files
  • URL normalization: Removes fragments, normalizes trailing slashes
  • robots.txt generation: User-agent + Allow + Sitemap reference
  • Valid XML: Proper XML escaping, sitemaps.org schema

Requirements

  • Python 3.6+
  • No external dependencies (stdlib only)