Skip to main content

High-performance RSS/Atom/JSON Feed parser with feedparser-compatible API

Project description

feedparser-rs

PyPI Python License

High-performance RSS/Atom/JSON Feed parser for Python with feedparser-compatible API.

Features

  • Fast: Native Rust implementation via PyO3
  • HTTP fetching: Built-in URL fetching with compression (gzip, deflate, brotli)
  • Conditional GET: ETag/Last-Modified support for efficient polling
  • Tolerant parsing: Bozo flag for graceful handling of malformed feeds
  • Multi-format: RSS 0.9x/1.0/2.0, Atom 0.3/1.0, JSON Feed 1.0/1.1
  • Podcast support: iTunes and Podcast 2.0 namespace extensions
  • feedparser-compatible: Dict-style access, field aliases, same API patterns
  • DoS protection: Built-in resource limits

Installation

pip install feedparser-rs

[!IMPORTANT] Requires Python 3.9 or later.

Usage

Basic Parsing

import feedparser_rs

# Parse from string, bytes, or URL (auto-detected)
d = feedparser_rs.parse('<rss>...</rss>')
d = feedparser_rs.parse(b'<rss>...</rss>')
d = feedparser_rs.parse('https://example.com/feed.xml')  # URL auto-detected

# Attribute-style access (feedparser-compatible)
print(d.feed.title)
print(d.version)  # "rss20", "atom10", etc.
print(d.bozo)     # True if parsing errors occurred

# Dict-style access (feedparser-compatible)
print(d['feed']['title'])
print(d['entries'][0]['link'])

for entry in d.entries:
    print(entry.title)
    print(entry.published_parsed)  # time.struct_time

[!NOTE] Date fields like published_parsed return time.struct_time for feedparser compatibility.

Fetching from URL

import feedparser_rs

# Option 1: Auto-detection (recommended)
d = feedparser_rs.parse('https://example.com/feed.xml')

# Option 2: Explicit URL function
d = feedparser_rs.parse_url('https://example.com/feed.xml')

# With conditional GET for efficient polling
d = feedparser_rs.parse(
    'https://example.com/feed.xml',
    etag=cached_etag,
    modified=cached_modified
)
if d.status == 304:
    print("Feed not modified")

# With custom limits
limits = feedparser_rs.ParserLimits(max_entries=100)
d = feedparser_rs.parse_with_limits('https://example.com/feed.xml', limits=limits)

[!TIP] URL fetching supports automatic compression (gzip, deflate, brotli) and follows redirects.

Migration from feedparser

feedparser-rs is designed as a drop-in replacement for Python feedparser:

# Drop-in replacement
import feedparser_rs as feedparser

# Same API patterns work
d = feedparser.parse('https://example.com/feed.xml')
print(d.feed.title)
print(d['feed']['title'])  # Dict-style access works too
print(d.entries[0].link)

# Deprecated field names supported
print(d.feed.description)  # → d.feed.subtitle
print(d.channel.title)     # → d.feed.title
print(d.items[0].guid)     # → d.entries[0].id

Supported Field Aliases

Old Name Maps To
feed.description feed.subtitle or feed.summary
feed.tagline feed.subtitle
feed.copyright feed.rights
feed.modified feed.updated
channel feed
items entries
entry.guid entry.id
entry.description entry.summary
entry.issued entry.published

Advanced Usage

Custom Resource Limits

import feedparser_rs

limits = feedparser_rs.ParserLimits(
    max_feed_size_bytes=50_000_000,  # 50 MB
    max_entries=5_000,
    max_authors=20,
    max_links_per_entry=50,
)

d = feedparser_rs.parse_with_limits(feed_data, limits=limits)

Format Detection

import feedparser_rs

version = feedparser_rs.detect_format(feed_data)
print(version)  # "rss20", "atom10", "json11", etc.

Podcast Support

import feedparser_rs

d = feedparser_rs.parse(podcast_feed)

# iTunes metadata
if d.feed.itunes:
    print(d.feed.itunes.author)
    print(d.feed.itunes.categories)

# Episode metadata
for entry in d.entries:
    if entry.itunes:
        print(f"Duration: {entry.itunes.duration}s")

API Reference

Functions

  • parse(source, etag=None, modified=None, user_agent=None) — Parse feed from bytes, str, or URL (auto-detected)
  • parse_url(url, etag=None, modified=None, user_agent=None) — Fetch and parse feed from URL
  • parse_with_limits(source, etag=None, modified=None, user_agent=None, limits=None) — Parse with custom resource limits
  • parse_url_with_limits(url, etag=None, modified=None, user_agent=None, limits=None) — Fetch and parse with custom limits
  • detect_format(source) — Detect feed format without full parsing

Classes

  • FeedParserDict — Parsed feed result (supports both attribute and dict-style access)

    • .feed / ['feed'] — Feed metadata
    • .entries / ['entries'] — List of entries
    • .bozo — True if parsing errors occurred
    • .version — Feed version string
    • .encoding — Character encoding
    • .status — HTTP status code (for URL fetches)
    • .etag — ETag header (for conditional GET)
    • .modified — Last-Modified header (for conditional GET)
  • ParserLimits — Resource limits configuration

Performance

Benchmarks vs Python feedparser on Apple M1 Pro:

Operation feedparser-rs Python feedparser Speedup
Parse 2 KB RSS 0.01 ms 0.9 ms 90x
Parse 20 KB RSS 0.09 ms 8.5 ms 94x
Parse 200 KB RSS 0.94 ms 85 ms 90x

[!TIP] For maximum performance, pass bytes instead of str to avoid UTF-8 re-encoding.

Platform Support

Pre-built wheels available for:

Platform Architecture
macOS Intel (x64), Apple Silicon (arm64)
Linux x64, arm64
Windows x64

Supported Python versions: 3.9, 3.10, 3.11, 3.12, 3.13

Development

git clone https://github.com/bug-ops/feedparser-rs
cd feedparser-rs/crates/feedparser-rs-py
pip install maturin
maturin develop

License

Licensed under either of:

at your option.

Links

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

feedparser_rs-0.4.1.tar.gz (173.4 kB view details)

Uploaded Source

Built Distributions

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

feedparser_rs-0.4.1-cp312-cp312-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.12Windows x86-64

feedparser_rs-0.4.1-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

feedparser_rs-0.4.1-cp312-cp312-macosx_10_12_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

feedparser_rs-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

feedparser_rs-0.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

File details

Details for the file feedparser_rs-0.4.1.tar.gz.

File metadata

  • Download URL: feedparser_rs-0.4.1.tar.gz
  • Upload date:
  • Size: 173.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for feedparser_rs-0.4.1.tar.gz
Algorithm Hash digest
SHA256 8059f0226104ae8cf02292b367cbd3f4e0b1810ad44f38dbaf8036d9ead90fdd
MD5 99c2f3ba10a0f682d69fd63680e880b9
BLAKE2b-256 59118050441cbae70ea33b763bb639aed6a53a02c409aae5fb25e8c071ecf89e

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.1.tar.gz:

Publisher: release.yml on bug-ops/feedparser-rs

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

File details

Details for the file feedparser_rs-0.4.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e03bbec86a26685bbca95206a17f22b72950e27fb03a3410eb44a101014f916c
MD5 a943732567f06228e110705256e9291d
BLAKE2b-256 5a4051924e89127d0ec10ee4d0aa1687c384090396154156dadaab23ad3bbd1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.1-cp312-cp312-win_amd64.whl:

Publisher: release.yml on bug-ops/feedparser-rs

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

File details

Details for the file feedparser_rs-0.4.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9eef00e900ffef078ea78daa8e1f08852b5524df3e096f26889f13802d377dd
MD5 36013e062eb04ea12a9c347c36d8ab55
BLAKE2b-256 25740293126bb1663b9a6180999de34e0b3c024fe53b4465342e3a85911d6623

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on bug-ops/feedparser-rs

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

File details

Details for the file feedparser_rs-0.4.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9378e5c0cac802fb89528d849802ece1d3400c1959e28480900c1e1d749da333
MD5 804d89a629286c4209a6f353b97c5e99
BLAKE2b-256 f5034be65e38851cfb89b26f9ee34335a4ce6c87afa462165087fad3c698d1cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.1-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: release.yml on bug-ops/feedparser-rs

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

File details

Details for the file feedparser_rs-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 174f7d185e4c5967bdd6e3a4e56b126934761f91e33de8b5512723e6f3049651
MD5 7bf51ab1bdd37381606c49430e37f5a0
BLAKE2b-256 6937f669b206cc53aee253e38d733d0f1801878c9d0ecc42057005351c0b9d1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on bug-ops/feedparser-rs

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

File details

Details for the file feedparser_rs-0.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f23cb1188c33e26458e1e06a4f400b8c537cd632f11b0db1e71e332020cb73cd
MD5 a772309ee6e1c3570ae4f61326989a1b
BLAKE2b-256 953ac3553fbafb0a36f1edb32347b31fe12d7b75fcccd14e6018f9cfc797719e

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on bug-ops/feedparser-rs

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