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.2.tar.gz (176.8 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.2-cp312-cp312-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

feedparser_rs-0.4.2-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.2-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.2-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.2.tar.gz.

File metadata

  • Download URL: feedparser_rs-0.4.2.tar.gz
  • Upload date:
  • Size: 176.8 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.2.tar.gz
Algorithm Hash digest
SHA256 eace1ab32162eb97fa9aeb11293e2ab385a19a51ec9458ed2c7f6b39fcf099f8
MD5 642f03e72241406821b58fd33138b73c
BLAKE2b-256 910dc1917557ad381a318ea5b18be0e10d116e7b2d3fa56dfd86f6768ef04fbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.2.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.2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9cfd94f41373a1e3a782a597b800f244bdddabbb167edf82d25ec90a4f0cd984
MD5 11c1c09afbd72e1474fbd3a6031c22fc
BLAKE2b-256 483f0ccca37293db1701044bc86555875e3eac4c27678eaea70f084ad2908dd1

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.2-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.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce1927f8e3d4d951a61465a9b821c28eca7c7b6b64619165f40f92941891f071
MD5 5f1c2606e34697eec5db24d3e4c7d240
BLAKE2b-256 7ceb34745139358c7fa245a8f951834f478db9f32e7717fb78e7c6b305e356fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.2-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.2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3f00d52459ff453a0b7439767e3cbfa7321dc77cd3eefad1bd86215cca1020f9
MD5 7307cc933450d127bad5e21e66c9bc63
BLAKE2b-256 df7fdae317f18c4b39e95df3193b50396906387a7d75914f2ade9bb0232cfb60

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.2-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.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7739799aa8ffe681cabf4519d4257e58772dd10f95fb62133ba6b60060dfa6db
MD5 a0f8f3e303b7bd645f1f76a77478becf
BLAKE2b-256 f349ea2a1d375762fba50669823527bc10f9b054b5acd7749b385d05305832bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.2-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.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for feedparser_rs-0.4.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 891da4d03b9a0af692eb96acfb5979f026592930c445ae091fc9a5cc2ad8b5bf
MD5 a506f36da217f4f5b6ef94afbc0ae6bf
BLAKE2b-256 7ae99e7cbb0867fdb5bd3b42268fa4a49900518f138c2213fca5b3e55f4c51ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for feedparser_rs-0.4.2-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