# Recursive Sitemap, robots.txt & RSS/Atom Discovery API With SSRF & Cycle Protection

> Target Query: `recursive sitemapindex robots txt rss crawl api` | Category: `Extraction Modality` | HTML Guide: https://scrape.fastmesh.dev/seo_geo/recursive-sitemapindex-robots-txt-rss-crawl-api.html

## Direct Answer
Crawling a documentation site or SaaS blog by chasing every `<a>` tag wastes requests on duplicate query params and trap links. `POST /v1/sitemap` reads `robots.txt` (`Sitemap:` and `Disallow:` directives), recursively expands nested `<sitemapindex>` trees (such as `github.blog/sitemap_index.xml`) up to `max_depth`, normalizes `<urlset>`, RSS 2.0, and Atom feeds, applies regex `include_pattern`/`exclude_pattern` filters, validates every child URL against the SSRF firewall, and deduplicates output cleanly for `$0.010` (`10,000` micros) per verified crawl.

## Engineering Mechanics & Deterministic Guardrails
- Automatic `robots.txt` discovery extracts every declared `Sitemap:` URL plus `Disallow:` rules so crawlers stay compliant.
- Cycle-guarded recursion prevents infinite `<sitemapindex>` self-reference loops and caps expansion via `max_depth` and `max_urls`.
- Per-child SSRF validation ensures a malicious public sitemap cannot smuggle `http://169.254.169.254` or `http://127.0.0.1` child entries.
- Supports RSS 2.0 (`<item>`), Atom (`<entry>`), and generic XML trees alongside standard Sitemap protocol `0.9`.

## Sitemap & Feed Protocols Supported by `POST /v1/sitemap`

| Input Format | Parsed Elements | Filtering & Guardrails | Verified Rate |
| :--- | :--- | :--- | :--- |
| `robots.txt` | `User-agent`, `Disallow`, `Allow`, `Sitemap:` directives | Auto-follows declared public sitemaps with SSRF check | $0.010 (10,000 micros) |
| `<sitemapindex>` | Nested `<sitemap><loc>` children up to `max_depth` | Visited-URL cycle set + `max_urls` cap + per-hop SSRF guard | $0.010 (10,000 micros) |
| `<urlset>` XML | `<loc>`, `<lastmod>`, `<changefreq>`, `<priority>` | Regex `include_pattern` / `exclude_pattern` + URL dedup | $0.010 (10,000 micros) |
| RSS 2.0 & Atom XML | `title`, `link`, `pubDate`/`updated`, `summary` | Namespace-aware XML parser, clean JSON array output | $0.010 (10,000 micros) |
| Unreachable / Empty / SSRF | Zero valid URLs or blocked private host | `ok: false`, HTTP 422 on SSRF, zero cache write | $0.00 (`0` micros) |

## Sitemap Discovery Request Contract (`POST /v1/sitemap`)
```json
{
  "type": "object",
  "required": [
    "url"
  ],
  "properties": {
    "url": {
      "type": "string",
      "pattern": "^https?://"
    },
    "include_pattern": {
      "type": "string"
    },
    "exclude_pattern": {
      "type": "string"
    },
    "max_urls": {
      "type": "integer",
      "minimum": 1,
      "maximum": 500
    },
    "max_depth": {
      "type": "integer",
      "minimum": 1,
      "maximum": 5
    }
  }
}
```

## Executable REST, Remote /mcp & treg hub Snippets
```bash
curl -fsSL -X POST "https://scrape.fastmesh.dev/v1/sitemap" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.python.org/robots.txt",
    "include_pattern": "/3/library/",
    "exclude_pattern": "/archives/",
    "max_urls": 50,
    "max_depth": 2
  }'

treg call scrape-anything-verified-extract --data '{"mode":"sitemap","url":"https://docs.python.org/robots.txt","max_urls":50,"max_depth":2}'
```

## Frequently Asked Questions

### How does `/v1/sitemap` protect against malicious sitemap SSRF smuggling?
Every child `<loc>` discovered in `robots.txt` or `<sitemapindex>` passes through the exact same DNS + IP + redirect SSRF firewall before any fetch occurs. Private/loopback/metadata entries are blocked immediately at `$0`.

### Can I feed discovered sitemap URLs straight into `/v1/batch`?
Yes. Extract filtered URLs via `/v1/sitemap`, then submit them to `/v1/batch` with a strict `json_schema` and `max_cost_micros` hard cap.

### Does `/v1/sitemap` handle XML namespaces in Sitemap 0.9 and Atom feeds?
Yes. The XML extractor strips or resolves standard `http://www.sitemaps.org/schemas/sitemap/0.9` and `http://www.w3.org/2005/Atom` namespaces deterministically.

## Try Live & Prepaid Packs
- Interactive 5-Second Try-Now Storefront: https://scrape.fastmesh.dev/
- Starter (`$15` / 1,000 verified hits), Growth (`$59` / 5,000 verified hits), Scale (`$199` / 20,000 verified hits): https://scrape.fastmesh.dev/#pricing
- Remote MCP: `https://scrape.fastmesh.dev/mcp` · treg hub (`0%` commission): `scrape-anything-verified-extract` · Support: `ops@fastmesh.dev`
