# XML/Gzip Sitemap URL Discovery & SEO Metadata Extractor (`apex-b2b-data/sitemap-url-metadata-extractor`) Actor

Discover, parse, and filter XML and .xml.gz sitemaps (including nested sitemap indexes and robots.txt auto-discovery). Filter by regex, keywords, or lastmod date, and enrich URLs with live page titles, meta descriptions, canonical URLs, H1 headers, word counts, and HTTP status codes.

- **URL**: https://apify.com/apex-b2b-data/sitemap-url-metadata-extractor.md
- **Developed by:** [George Barnes](https://apify.com/apex-b2b-data) (community)
- **Categories:** SEO tools, AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.05 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## XML Sitemap & URL Metadata Extractor (`$1.50 / 1K`)

**Extract, filter, and enrich all URLs from any website's XML sitemaps—supporting nested sitemap indexes, `.xml.gz` archives, and automated `robots.txt` auto-discovery—enriched with live HTML title, meta description, canonical URL, H1 header, word count, HTTP status, and response latency.**

Unlike basic scrapers that crash on nested indexes or simply dump raw URL strings, this Actor provides an **end-to-end SEO, technical audit, and website inventory engine** that runs with zero proxy costs and zero required API keys.

***

### Why Choose This Sitemap Extractor? (Comparison)

| Capability | This Actor | Basic Sitemap Scrapers | Traditional Web Crawlers |
| :--- | :--- | :--- | :--- |
| **Price per 1,000 URLs** | **`$1.50 / 1K` (`$0.0015` / URL)** | `$3.00 – $10.00 / 1K` or subscription | High compute & residential proxy costs |
| **Nested Sitemap Index Support** | ✅ Recursive traversal (`maxDepth`) | ❌ Fails or only takes first child | N/A (Crawls blindly) |
| **Compressed `.xml.gz` Decompression** | ✅ Transparent gzip decompression | ⚠️ Often errors on gzip bytes | ❌ N/A |
| **`robots.txt` Auto-Discovery** | ✅ Discovers declared `Sitemap:` directives | ❌ Manual URL input required | ❌ No |
| **Live HTML Metadata Enrichment** | ✅ Title, Meta Desc, Canonical, H1, Words | ❌ Raw URL strings only | ⚠️ Heavy headless browsers required |
| **Regex & Substring Keyword Filters** | ✅ `urlFilterRegex`, `includeKeywords` | ❌ None or basic starts-with | ⚠️ Complex scraper rules needed |
| **Last-Modified (`lastmod`) Date Filter** | ✅ Extract only URLs updated since date | ❌ Ignores XML `lastmod` | ❌ Cannot detect XML dates |
| **Asset Extension Auto-Filtering** | ✅ Strips `.png`, `.jpg`, `.pdf`, `.zip`, etc. | ❌ Dumps image/pdf URLs | ⚠️ Manual filter setup |
| **Concurrent Async Execution** | ✅ Multithreaded fetch & enrichment | ⚠️ Slow sequential requests | ⚠️ High RAM usage |
| **Zero Proxy Costs & 100% Reliability** | **`$0.00` (Direct HTTP, 0% failure)** | `$0.00` | Requires expensive rotating proxies |

***

### Transparent Pricing (`$1.50` per 1,000 URLs)

You are charged **only for URLs actually extracted and enriched** (`$0.0015` per record via Apify Pay-Per-Event pricing), with no mandatory monthly subscription:

| Workflow | URLs Extracted | Total Cost |
| :--- | :--- | :--- |
| **Fast Trial Run** (verify output schema) | `10` URLs | **`$0.015` (~1.5 cents)** |
| **Competitor Blog / Article Tracking** | `250` URLs | **`$0.375` (~38 cents)** |
| **Complete Site Inventory & SEO Audit** | `1,000` URLs | **`$1.50`** |
| **Large E-Commerce Product Catalog** | `10,000` URLs | **`$15.00`** |
| **Enterprise Multi-Domain Audit** | `50,000` URLs | **`$75.00`** |

***

### Production B2B Playbooks (Copy-Paste Inputs)

#### 1. Complete Website SEO Audit & Meta Tag Extraction

Audit any website's declared pages, extracting title tags, meta descriptions, canonical URLs, and H1 tags to spot missing metadata or duplicate content:

```json
{
  "sitemapUrls": ["https://apify.com/sitemap.xml"],
  "enrichMetadata": true,
  "maxUrls": 100,
  "timeoutSec": 15
}
```

#### 2. Competitor Blog & Content Publishing Tracker (Filtered by `lastmod`)

Monitor fresh content published or updated since a specific date, filtering specifically for articles and blog posts:

```json
{
  "sitemapUrls": ["https://example.com/sitemap.xml"],
  "includeKeywords": ["/blog/", "/articles/", "/news/"],
  "lastmodSince": "2024-01-01",
  "enrichMetadata": true,
  "maxUrls": 500
}
```

#### 3. E-Commerce Product Catalog URL & Title Extraction

Extract product page links and titles by matching URL regex patterns while excluding images, PDFs, and static assets:

```json
{
  "sitemapUrls": ["https://store.example.com/sitemap_products_1.xml.gz"],
  "urlFilterRegex": "^https://store\\.example\\.com/products/",
  "excludeKeywords": [".png", ".jpg", ".webp", ".pdf", "/collections/"],
  "enrichMetadata": true,
  "maxUrls": 1000
}
```

#### 4. Domain Architecture & `robots.txt` Auto-Discovery

Pass domain names without knowing their sitemap location; the Actor inspects `robots.txt` to automatically locate all registered sitemaps and indexes:

```json
{
  "targetDomains": ["apify.com", "github.com"],
  "discoverFromRobotsTxt": true,
  "enrichMetadata": true,
  "maxUrls": 50
}
```

***

### Sample Output Record

Each item emitted in the dataset contains all 11 core transformation fields:

```json
{
  "url": "https://apify.com/about",
  "sitemap_source": "https://apify.com/sitemap/pages.xml",
  "lastmod": "2024-10-15T08:30:00Z",
  "changefreq": "monthly",
  "priority": 0.8,
  "page_title": "About · Apify",
  "meta_description": "We're building the largest marketplace of tools for AI: the place where builders, businesses, and agents find ready-to-run tools for work on the web.",
  "canonical_url": "https://apify.com/about",
  "h1_header": "About Apify",
  "word_count": 808,
  "http_status": 200,
  "response_time_ms": 217.89,
  "discovered_at": "2026-11-04T00:19:24.071636+00:00"
}
```

***

### Integrations

#### Python (Apify Client)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run_input = {
    "sitemapUrls": ["https://apify.com/sitemap.xml"],
    "enrichMetadata": True,
    "maxUrls": 50,
}

run = client.actor("your-username/sitemap-url-metadata-extractor").call(run_input=run_input)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(f"[{item['http_status']}] {item['url']} -> {item['page_title']}")
```

#### Direct REST API (Synchronous Execution for Clay, n8n, Make)

Trigger the Actor synchronously and retrieve dataset items directly in one HTTP POST:

```bash
curl -X POST "https://api.apify.com/v2/acts/your-username~sitemap-url-metadata-extractor/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "sitemapUrls": ["https://apify.com/sitemap.xml"],
    "enrichMetadata": true,
    "maxUrls": 25
  }'
```

#### Model Context Protocol (MCP) Tool Definition

```json
{
  "name": "extract_sitemap_metadata",
  "description": "Parse XML sitemaps, sitemap indexes, and enrich URLs with page title, meta description, canonical URL, and word count.",
  "parameters": {
    "type": "object",
    "properties": {
      "sitemapUrls": {
        "type": "array",
        "items": { "type": "string" },
        "description": "List of sitemap URLs to parse."
      },
      "enrichMetadata": {
        "type": "boolean",
        "description": "Whether to fetch HTML to extract titles and meta tags."
      },
      "maxUrls": {
        "type": "integer",
        "description": "Maximum URLs to return."
      }
    },
    "required": ["sitemapUrls"]
  }
}
```

# Actor input Schema

## `sitemapUrls` (type: `array`):

Direct URLs to XML sitemaps or .xml.gz files (e.g., https://apify.com/sitemap.xml). Nested sitemap indexes are recursively traversed automatically.

## `targetDomains` (type: `array`):

Root domain names (e.g. \['apify.com']). If provided and robots.txt discovery is enabled, sitemaps will be auto-discovered from robots.txt.

## `discoverFromRobotsTxt` (type: `boolean`):

Automatically query target domains' /robots.txt files to discover declared Sitemap directives and fall back to standard paths.

## `enrichMetadata` (type: `boolean`):

Fetch each discovered URL to extract page title, meta description, canonical link, H1 header, word count, HTTP status, and response latency.

## `urlFilterRegex` (type: `string`):

Optional regular expression pattern. If specified, only URLs matching this regex pattern will be collected and enriched.

## `includeKeywords` (type: `array`):

Optional list of substrings. If provided, only URLs containing at least one of these substrings will be kept (e.g. \['/blog/', '/store/']).

## `excludeKeywords` (type: `array`):

URLs containing any of these substrings or asset extensions will be ignored.

## `lastmodSince` (type: `string`):

Filter URLs modified on or after this date/time (e.g. '2024-01-01' or '2025-06-01T00:00:00Z'). URLs with missing or earlier lastmod timestamps are skipped.

## `maxUrls` (type: `integer`):

Maximum number of filtered and enriched page URLs to output in the dataset. Default is 10 for fast trials.

## `maxDepth` (type: `integer`):

Maximum recursion depth when following nested sitemap index references (default: 3).

## `concurrency` (type: `integer`):

Number of concurrent worker threads for downloading sitemaps and enriching HTML page metadata.

## `timeoutSec` (type: `integer`):

Timeout in seconds for downloading sitemaps and individual page URLs.

## Actor input object example

```json
{
  "sitemapUrls": [
    "https://apify.com/sitemap.xml"
  ],
  "targetDomains": [],
  "discoverFromRobotsTxt": true,
  "enrichMetadata": true,
  "urlFilterRegex": "",
  "includeKeywords": [],
  "excludeKeywords": [
    ".png",
    ".jpg",
    ".jpeg",
    ".gif",
    ".svg",
    ".webp",
    ".pdf",
    ".zip",
    ".gz"
  ],
  "lastmodSince": "",
  "maxUrls": 10,
  "maxDepth": 3,
  "concurrency": 8,
  "timeoutSec": 15
}
```

# Actor output Schema

## `results` (type: `string`):

Structured JSON records produced by XML/Gzip Sitemap URL Discovery & SEO Metadata Extractor in the default dataset.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "sitemapUrls": [
        "https://apify.com/sitemap.xml"
    ],
    "excludeKeywords": [
        ".png",
        ".jpg",
        ".jpeg",
        ".gif",
        ".svg",
        ".webp",
        ".pdf",
        ".zip",
        ".gz"
    ],
    "maxUrls": 10,
    "concurrency": 8,
    "timeoutSec": 15
};

// Run the Actor and wait for it to finish
const run = await client.actor("apex-b2b-data/sitemap-url-metadata-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "sitemapUrls": ["https://apify.com/sitemap.xml"],
    "excludeKeywords": [
        ".png",
        ".jpg",
        ".jpeg",
        ".gif",
        ".svg",
        ".webp",
        ".pdf",
        ".zip",
        ".gz",
    ],
    "maxUrls": 10,
    "concurrency": 8,
    "timeoutSec": 15,
}

# Run the Actor and wait for it to finish
run = client.actor("apex-b2b-data/sitemap-url-metadata-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sitemapUrls": [
    "https://apify.com/sitemap.xml"
  ],
  "excludeKeywords": [
    ".png",
    ".jpg",
    ".jpeg",
    ".gif",
    ".svg",
    ".webp",
    ".pdf",
    ".zip",
    ".gz"
  ],
  "maxUrls": 10,
  "concurrency": 8,
  "timeoutSec": 15
}' |
apify call apex-b2b-data/sitemap-url-metadata-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,apex-b2b-data/sitemap-url-metadata-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/f0v2CQKoRbLpUCLxG/builds/lq4sv6Ea55D8JhkJO/openapi.json
