Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

rlnorthcutt/sitemapExport

Open more actions menu

Repository files navigation

sitemapExport

sitemapExport is a Go-based CLI tool that crawls a sitemap or RSS feed, extracts content from web pages using CSS selectors, and compiles the data into various formats such as txt, json, jsonl, and md.

The primary use case is to extract content into a file that can be used as contextual data for AI. For example, extracting your docs site as a structured text or JSON file to power a solid AI support chatbot (tutorial here).

Features

  • Crawl a sitemap or RSS feed to extract content from pages.
  • Extract page content using a specified CSS selector.
  • Optionally filter URLs with a simple pattern (e.g., blog/*).
  • Generate a structured list of pages with:
    • Page title
    • URL
    • Meta description (if available)
    • Meta tags (if available)
    • Extracted content
  • Output formats supported:
    • Plain text (txt)
    • JSON (json)
    • JSON Lines (jsonl)
    • Markdown (md)
  • Supports non-interactive usage via flags or environment variables.

Installation

Easy: Run the binary

Grab the pre-built sitemapExport binary from the releases page, make it executable, and run it.

Build from source

Requires Go 1.23 or later.

  1. Clone the repository:

    git clone https://github.com/rlnorthcutt/sitemapExport.git
    cd sitemapExport
  2. Build the binary:

    go build

    For a smaller binary:

    go build -ldflags="-s -w"

Usage

The tool supports interactive prompts, command-line flags, and environment variables. Flags take priority over environment variables, which take priority over interactive prompts.

Interactive

./sitemapExport

Example session:

Enter the Sitemap or RSS feed URL or file path (required): https://example.com/sitemap.xml
Enter the CSS selector to extract content (default: body):
Enter the output filename (default: output):
Enter the URL filter pattern (default: *):
Enter the output file type (txt, json, jsonl, md) (default: txt): jsonl

Export data with the following settings:
  Input:           https://example.com/sitemap.xml
  CSS Selector:    body
  URL Filter:      *
  Output Filename: output
  Output Filetype: jsonl
  Format:          txt

Do you want to proceed with these settings? (y/n): y

Non-interactive (flags)

./sitemapExport --input="https://example.com/sitemap.xml" --css="article" --filename="output" --type="jsonl" --filter="blog/*"

Short flags are also supported:

./sitemapExport -i "https://example.com/sitemap.xml" -c "article" -n "output" -t "jsonl"

Flags

Flag Short Default Description
--input -i (required) Sitemap or RSS feed URL, or local file path
--css -c body CSS selector to extract content
--filename -n output Output filename (without extension)
--type -t txt Output format: txt, json, jsonl, md
--filter * Only include URLs matching this pattern (e.g., blog/*)
--verbose -v false Enable verbose output

Environment variables

All inputs can also be set via environment variables, which are checked when a flag is not explicitly provided:

Variable Corresponding flag
SITEMAP_INPUT --input
SITEMAP_CSS --css
SITEMAP_FILENAME --filename
SITEMAP_TYPE --type
SITEMAP_FILTER --filter

Output formats

  • txt — plain text, one page per section
  • json — pretty-printed JSON array
  • jsonl — one JSON object per line (ideal for AI ingestion pipelines)
  • md — Markdown with headings and content

Example output

JSON (output.json):

[
  {
    "Title": "Home",
    "URL": "https://example.com",
    "Description": "Welcome to our homepage",
    "Content": "Welcome to our site!"
  },
  {
    "Title": "About Us",
    "URL": "https://example.com/about",
    "Description": "Learn more about our company",
    "Content": "We are a company..."
  }
]

JSON Lines (output.jsonl):

{"Title":"Home","URL":"https://example.com/","Description":"Welcome to our homepage","Content":"Welcome to our site!"}
{"Title":"About Us","URL":"https://example.com/about","Description":"Learn more about our company","Content":"We are a company..."}

Project structure

sitemapExport/
├── main.go           # CLI entry point, flag definitions, orchestration
├── crawler/          # Sitemap and RSS crawling, page extraction
│   └── crawler.go
├── formatter/        # Formats extracted pages into output formats
│   └── formatter.go
├── writer/           # Writes formatted content to disk
│   └── writer.go
├── feed/             # Feed type detection (sitemap vs RSS)
│   └── feed.go
├── html2text/        # HTML to plain text conversion
│   └── html2text.go
├── go.mod
└── go.sum

Dependencies

Contributing

Feel free to open issues or submit pull requests for new features, bug fixes, or general improvements.

License

This project is licensed under the MIT License.

About

SitemapExport is a Go-based CLI tool that crawls sitemaps, extracts webpage content using CSS selectors, and compiles the data into various formats (txt, json, jsonl, md, pdf).

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.