Skip to main content

A tool to convert XML sitemaps to Atom feeds

Project description

sitemap2atom

A simple tool to convert an XML sitemap into an Atom feed — especially useful for sites that don't have a CMS, or where the CMS doesn't produce a feed. Each URL in the sitemap is fetched and its OpenGraph and Twitter Card metadata (title, description, image, author, dates) is used to build a rich Atom entry.

Installation

Run without installing (uvx)

Once published to PyPI you can run it directly with uv:

uvx sitemap2atom https://example.com/sitemap.xml -o feed.atom

To run the latest code straight from GitHub (before a release, or to try main):

uvx --from git+https://github.com/darkflib/sitemap2atom sitemap2atom https://example.com/sitemap.xml

Install as a tool / library

uv tool install sitemap2atom      # installs the `sitemap2atom` command
# or
pip install sitemap2atom

Usage

sitemap2atom SITEMAP_URL [OPTIONS]

By default the feed is written to standard output; redirect it or use -o to save it to a file:

# Print to stdout
sitemap2atom https://example.com/sitemap.xml

# Write to a file, limiting to the first 20 URLs
sitemap2atom https://example.com/sitemap.xml -o feed.atom --limit 20

Options

  • -o, --output PATH — write the Atom feed to this file (default: stdout).
  • --limit N — maximum number of sitemap URLs to process (default: all).
  • --feed-title TEXT — title for the generated feed (default: Enriched URL Feed).
  • --timeout SECONDS — per-request timeout in seconds (default: 10).
  • -v, --verbose — enable info-level logging on stderr.
  • --version — show the version and exit.

As a library

from sitemap2atom import fetch_sitemap_urls, enrich_url_list_to_atom, feed_to_pretty_xml

urls = fetch_sitemap_urls("https://example.com/sitemap.xml")
feed = enrich_url_list_to_atom(urls[:10], feed_title="My Feed")
print(feed_to_pretty_xml(feed))

Example output

See this gist for a sample of the kind of enriched Atom feed produced: https://gist.github.com/Darkflib/989b8f3a5a1ea995e8e294669d5e282a

Limitations

This is a simple tool aimed at basic use cases. It does not support authentication, sitemap index files / pagination, or dynamic sitemaps, and may not handle every sitemap or page format. Treat the sitemap and the pages it references as untrusted input and run it against sources you trust.

Some sites sit behind bot-protection that serves a JavaScript "verify your device" challenge instead of the real content. sitemap2atom sends browser-like headers, which is enough for many of these, but sites that require JavaScript execution cannot be fetched by a simple HTTP client. In that case you'll see a clear error explaining that an HTML page was returned instead of a sitemap.

Development

This project uses uv.

git clone https://github.com/darkflib/sitemap2atom.git
cd sitemap2atom
uv sync
uv run pytest

See CONTRIBUTING.md for more, and CHANGELOG.md for release notes.

License

This project is licensed under the MIT License — see the LICENSE file for details.

PS. If you do anything interesting with this code, please let me know! I'd love to hear about it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sitemap2atom-0.1.1.tar.gz (52.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sitemap2atom-0.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file sitemap2atom-0.1.1.tar.gz.

File metadata

  • Download URL: sitemap2atom-0.1.1.tar.gz
  • Upload date:
  • Size: 52.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sitemap2atom-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b4f36c72213b954d0c5822720d2c3658206c2f2a17822ba714fca2f4c2650230
MD5 f112f2ebfa203f72949394246eb24381
BLAKE2b-256 58461ffe5cbfac3500ce7c0a6ab0c4daee9b7218e037bb3773a85b1ac452fc73

See more details on using hashes here.

Provenance

The following attestation bundles were made for sitemap2atom-0.1.1.tar.gz:

Publisher: workflow.yml on Darkflib/sitemap2atom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sitemap2atom-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sitemap2atom-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sitemap2atom-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1123a45f6005ccc0cdcd64d4506d511f9faa51fc610fcf79341133bd9bc72fbf
MD5 4085af93518c1cc5a12d19164e5087ec
BLAKE2b-256 c733e112e23c3d88efb90abfa0044333bcc6c01184924b01311d099fc9a58782

See more details on using hashes here.

Provenance

The following attestation bundles were made for sitemap2atom-0.1.1-py3-none-any.whl:

Publisher: workflow.yml on Darkflib/sitemap2atom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page