Skip to main content
PyPI Version Wheel Status Testing status Coverage report Supported python versions

Tools to easy generate RSS feed that contains each scraped item using Scrapy framework.

Table of Contents

Installation

  • Install scrapy_rss using pip

    pip install scrapy_rss

    or using pip for the specific interpreter, e.g.:

    pip3 install scrapy_rss
  • or using setuptools directly:

    cd path/to/root/of/scrapy_rss
    python setup.py install

    or using setuptools for specific interpreter, e.g.:

    cd path/to/root/of/scrapy_rss
    python3 setup.py install

How To Use

Configuration

Add parameters to the Scrapy project settings (settings.py file) or to the custom_settings attribute of the spider:

  1. Add item pipeline that export items to rss feed:

    ITEM_PIPELINES = {
        # ...
        'scrapy_rss.pipelines.FeedExportPipeline': 900,  # or another priority
        # ...
    }
  2. Add required feed parameters:

    FEED_FILE

    the absolute or relative file path where the result RSS feed will be saved. For example, feed.rss or output/feed.rss.

    FEED_TITLE

    the name of the channel (feed),

    FEED_DESCRIPTION

    the phrase or sentence that describes the channel (feed),

    FEED_LINK

    the URL to the HTML website corresponding to the channel (feed)

    FEED_FILE = 'path/to/feed.rss'
    FEED_TITLE = 'Some title of the channel'
    FEED_LINK = 'http://example.com/rss'
    FEED_DESCRIPTION = 'About channel'

Usage

Basic usage

Declare your item directly as RssItem():

import scrapy_rss

item1 = scrapy_rss.RssItem()

Or use predefined item class RssedItem with RSS field named as rss that’s instance of RssItem:

import scrapy
import scrapy_rss

class MyItem(scrapy_rss.RssedItem):
    field1 = scrapy.Field()
    field2 = scrapy.Field()
    # ...

item2 = MyItem()

Set/get item fields. Case sensitive attributes of RssItem() are appropriate to RSS elements. Attributes of RSS elements are case sensitive too. If the editor allows autocompletion then it suggests attributes for instances of RssedItem and RssItem. It’s allowed to set any subset of RSS elements (e.g. title only). For example:

from datetime import datetime

item1.title = 'RSS item title'  # set value of <title> element
title = item1.title.value  # get value of <title> element
item1.description = 'description'

item1.guid = 'item identifier'
item1.guid.isPermaLink = False  # set value of attribute isPermalink of <guid> element,
                                # isPermaLink is True by default
is_permalink = item1.guid.isPermaLink  # get value of attribute isPermalink of <guid> element
guid = item1.guid.value  # get value of element <guid>

item1.category = 'single category'
category = item1.category
item1.category = ['first category', 'second category']
first_category = item1.category[0].value # get value of the element <category> with multiple values
all_categories = [cat.value for cat in item1.category]

# direct attributes setting
item1.enclosure.url = 'http://example.com/file'
item1.enclosure.length = 0
item1.enclosure.type = 'text/plain'

# or dict based attributes setting
item1.enclosure = {'url': 'http://example.com/file', 'length': 0, 'type': 'text/plain'}
item1.guid = {'value': 'item identifier', 'isPermaLink': True}

item1.pubDate = datetime.now()  # correctly works with Python' datetimes


item2.rss.title = 'Item title'
item2.rss.guid = 'identifier'
item2.rss.enclosure = {'url': 'http://example.com/file', 'length': 0, 'type': 'text/plain'}

All allowed elements are listed in the scrapy_rss/items.py. All allowed attributes of each element with constraints and default values are listed in the scrapy_rss/elements.py. Also you can read RSS specification for more details.

RssItem derivation and namespaces

You can extend RssItem to add new XML fields that can be namespaced or not. You can specify namespaces in an attribute and/or an element constructors. Namespace prefix can be specified in the attribute/element name using double underscores as delimiter (prefix__name) or in the attribute/element constructor using ns_prefix argument. Namespace URI can be specified using ns_uri argument of the constructor.

from scrapy_rss.meta import ElementAttribute, Element
from scrapy_rss.items import RssItem

class Element0(Element):
    # attributes without special namespace
    attr0 = ElementAttribute(is_content=True, required=True)
    attr1 = ElementAttribute()

class Element1(Element):
    # attribute "prefix2:attr2" with namespace xmlns:prefix2="id2"
    attr2 = ElementAttribute(ns_prefix="prefix2", ns_uri="id2")

    # attribute "prefix3:attr3" with namespace xmlns:prefix3="id3"
    prefix3__attr3 = ElementAttribute(ns_uri="id3")

    # attribute "prefix4:attr4" with namespace xmlns:prefix4="id4"
    fake_prefix__attr4 = ElementAttribute(ns_prefix="prefix4", ns_uri="id4")

    # attribute "attr5" with default namespace xmlns="id5"
    attr5 = ElementAttribute(ns_uri="id5")

class MyXMLItem(RssItem):
    # element <elem1> without namespace
    elem1 = Element0()

    # element <elem_prefix2:elem2> with namespace xmlns:elem_prefix2="id2e"
    elem2 = Element0(ns_prefix="elem_prefix2", ns_uri="id2e")

    # element <elem_prefix3:elem3> with namespace xmlns:elem_prefix3="id3e"
    elem_prefix3__elem3 = Element1(ns_uri="id3e")

    # yet another element <elem_prefix4:elem3> with namespace xmlns:elem_prefix4="id4e"
    # (does not conflict with previous one)
    fake_prefix__elem3 = Element0(ns_prefix="elem_prefix4", ns_uri="id4e")

    # element <elem5> with default namespace xmlns="id5e"
    elem5 = Element0(ns_uri="id5e")

Access to elements and its attributes is the same as with simple items:

item = MyXMLItem()
item.title = 'Some title'
item.elem1.attr0 = 'Required content value'
item.elem1 = 'Another way to set content value'
item.elem1.attr1 = 'Some attribute value'
item.elem_prefix3__elem3.prefix3__attr3 = 'Yet another attribute value'
item.elem_prefix3__elem3.fake_prefix__attr4 = '' # non-None value is interpreted as assigned
item.fake_prefix__elem3.attr1 = 42

Several optional settings are allowed for namespaced items:

FEED_NAMESPACES

list of tuples [(prefix, URI), ...] or dictionary {prefix: URI, ...} of namespaces that must be defined in the root XML element

FEED_ITEM_CLASS or FEED_ITEM_CLS

main class of feed items (class object MyXMLItem or path to class "path.to.MyXMLItem"). Default value: RssItem. It’s used in order to extract all possible namespaces that will be declared in the root XML element.

Feed items do NOT have to be instances of this class or its subclass.

If these settings are not defined or only part of namespaces are defined then other used namespaces will be declared either in the <item> element or in its subelements when these namespaces are not unique. Each <item> element and its sublements always contains only namespace declarations of non-None attributes (including ones that are interpreted as element content).

Feed (Channel) Elements Customization [optionally]

If you want to change other channel parameters (such as language, copyright, managingEditor, webMaster, pubDate, lastBuildDate, category, generator, docs, cloud, ttl, image, rating, textInput, skipHours, skipDays) then define your own exporter that’s inherited from FeedItemExporter class and, for example, modify one or more children of self.channel Element (camelCase attributes naming):

from datetime import datetime
from scrapy_rss.rss import channel_elements
from scrapy_rss.exporters import FeedItemExporter

class MyRssItemExporter(FeedItemExporter):
   def __init__(self, *args, **kwargs):
      super(MyRssItemExporter, self).__init__(*args, **kwargs)
      self.channel.generator = 'Special generator'
      self.channel.language = 'en-us'
      self.channel.managingEditor = 'editor@example.com'
      self.channel.webMaster = 'webmaster@example.com'
      self.channel.copyright = 'Copyright 2025'
      self.channel.pubDate = datetime(2025, 9, 10, 13, 0, 0)

      self.channel.category = ['category 1', 'category 2']
      self.channel.category.append('category 3')
      self.channel.category.extend(['category 4', 'category 5'])

      # initialize image from dict
      self.channel.image = {
          'url': 'https://example.com/img.jpg',
          'description': 'Image link hover text',
      }
      # or initialize image from ImageElement
      self.channel.image = channel_elements.ImageElement(url='https://example.com/img.jpg')
      # or initialize image by each attribute
      self.channel.image.url = 'https://example.com/img.jpg' # required attribute of image
      self.channel.image.title = 'Image title' # optional
      self.channel.image.link = 'https://example.com/page' # optional
      self.channel.image.description = 'Image link hover text' # optional
      self.channel.image.width = 140 # optional
      self.channel.image.height = 350 # optional

      self.channel.docs = 'https://example.com/rss_docs'
      self.channel.cloud = {
          'domain': 'rpc.sys.com',
          'port': '80',
          'path': '/RPC2',
          'registerProcedure': 'myCloud.rssPleaseNotify',
          'protocol': 'xml-rpc'
      }
      self.channel.ttl = 60
      self.channel.rating = 4.0
      self.channel.textInput = channel_elements.TextInputElement(
          title='Input title',
          description='Description of input',
          name='Input name',
          link='http://example.com/cgi.py'
      )

      self.channel.skipHours = (0, 1, 3, 7, 23) # initialize list from iterable
      self.channel.skipHours = 12 # or initialize list with single value

      self.channel.skipDays = 14 # initialize list with single value
      self.channel.skipDays = [1, 14] # or initialize list from list

or modify kwargs arguments (snake_case arguments naming):

from scrapy_rss.exporters import FeedItemExporter

class MyRssItemExporter(FeedItemExporter):
   def __init__(self, *args, **kwargs):
      kwargs['generator'] = kwargs.get('generator', 'Special generator')
      kwargs['language'] = kwargs.get('language', 'en-us')
      kwargs['managing_editor'] = kwargs.get('managing_editor', 'editor@example.com')
      kwargs['managing_editor'] = kwargs.get('managing_editor', ('category 1', 'category 2'))
      kwargs['image'] = kwargs.get('image', {'url': 'https://example.com/img.jpg'})
      # etc.
      super(MyRssItemExporter, self).__init__(*args, **kwargs)

And add FEED_EXPORTER parameter to the Scrapy project settings or to the custom_settings attribute of the spider:

FEED_EXPORTER = 'myproject.exporters.MyRssItemExporter'

Backward compatibility notices

Since version 1.0.0 some classes have been renamed, but old-named classes have been kept and marked as deprecated for backward compatibility, so they can still be used.

But some elements of RssItem have some their attributes renamed in a backward incompatible way: almost all content attributes (text content of XML tag after exporting) are renamed to value to enhance code readability.

So if you do not want update your code expressions (such as an old-style item.title.title to a new-style item.title.value or item.guid.guid to item.guid.value) then you can easily import old-style classes

# old-style classes
from scrapy_rss.rss.old.items import RssItem, RssedItem

instead of new-style ones

# new-style classes
from scrapy_rss.items import RssItem, RssedItem

respectively.

Scrapy Project Examples

Examples directory contains several Scrapy projects with the scrapy_rss usage demonstration. It crawls this website whose source code is here.

Just go to the Scrapy project directory and run commands

scrapy crawl first_spider
scrapy crawl second_spider

Thereafter feed.rss and feed2.rss files will be created in the same directory.

Metadata

Release files for scrapy-rss 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrapy-rss 1.1.0
File Size Uploaded Provenance
scrapy_rss-1.1.0.tar.gz 299.9 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for scrapy-rss 1.1.0
File
scrapy_rss-1.1.0-py314-none-any.whl Python 3.14 none any Details
scrapy_rss-1.1.0-py313-none-any.whl Python 3.13 none any Details
scrapy_rss-1.1.0-py312-none-any.whl Python 3.12 none any Details
scrapy_rss-1.1.0-py311-none-any.whl Python 3.11 none any Details
scrapy_rss-1.1.0-py310-none-any.whl Python 3.10 none any Details
scrapy_rss-1.1.0-py39-none-any.whl Python 3.9 none any Details
scrapy_rss-1.1.0-py38-none-any.whl Python 3.8 none any Details
scrapy_rss-1.1.0-py37-none-any.whl Python 3.7 none any Details
scrapy_rss-1.1.0-py36-none-any.whl Python 3.6 none any Details
scrapy_rss-1.1.0-py35-none-any.whl Python 3.5 none any Details
scrapy_rss-1.1.0-py34-none-any.whl Python 3.4 none any Details
scrapy_rss-1.1.0-py33-none-any.whl Python 3.3 none any Details
scrapy_rss-1.1.0-py27-none-any.whl Python 2.7 none any Details

Total release size: 705.2 kB

Release files / scrapy_rss-1.1.0.tar.gz

Download URL scrapy_rss-1.1.0.tar.gz
Size 299.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e49979ac063467ea89b6417c2fb34664aa873544fe462f5d413803d120639656
BLAKE2b-256 checksum
How to use checksums
24daff7075c8347807fa87f80609dd28dcc2c1bc82b81617a1ce537eaab21f5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py314-none-any.whl

Download URL scrapy_rss-1.1.0-py314-none-any.whl
Size 30.8 kB
Tags Python 3.14
SHA-256 checksum
How to use checksums
0ecedc9873755216ac23d9f06a2cbeec362cc8cbf02b1df2d5fe23c547673175
BLAKE2b-256 checksum
How to use checksums
7fed867983a73b6ea916c08b1854b6452f10219d98a7bf97933b86bc374b4223
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py313-none-any.whl

Download URL scrapy_rss-1.1.0-py313-none-any.whl
Size 30.8 kB
Tags Python 3.13
SHA-256 checksum
How to use checksums
df7bb4ab7fadceba4efe1d91649e3eaf5b5f151b1bf8946816fb15e27646c9d8
BLAKE2b-256 checksum
How to use checksums
a4294b0f1675155cbe3ef838c7c1a0cea062fd497447e3c97554361ba355b5f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py312-none-any.whl

Download URL scrapy_rss-1.1.0-py312-none-any.whl
Size 30.8 kB
Tags Python 3.12
SHA-256 checksum
How to use checksums
4b8b2c44a8d4464ae7426ebdd54145ed33d41b3ab62b2ffc7a83af29b2817a8c
BLAKE2b-256 checksum
How to use checksums
5a2ccd85776f9b19dc228e354cc8e93af8979add36fb6313dcf8b9c33f60868e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py311-none-any.whl

Download URL scrapy_rss-1.1.0-py311-none-any.whl
Size 30.8 kB
Tags Python 3.11
SHA-256 checksum
How to use checksums
051111265def1ea802c8335424d59f8ac479fdd874fccf2b2be138165f9a5643
BLAKE2b-256 checksum
How to use checksums
aabea7e13dffe428edfa5beef6977d616f6c1603f4bbf01b7162532a617598ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py310-none-any.whl

Download URL scrapy_rss-1.1.0-py310-none-any.whl
Size 30.8 kB
Tags Python 3.10
SHA-256 checksum
How to use checksums
0642828944ff1550b2d015900bdaa93a2fa3c6e2dd53fd485077b241a94487cc
BLAKE2b-256 checksum
How to use checksums
ba570246eaf725fdc58ed7b0ce231888a94632c296d6974c54ea427843c8b874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py39-none-any.whl

Download URL scrapy_rss-1.1.0-py39-none-any.whl
Size 30.8 kB
Tags Python 3.9
SHA-256 checksum
How to use checksums
e4b634c714f168016e5feba13ae3aa90b9534e9c08ee6c92d314bfcb0477bb12
BLAKE2b-256 checksum
How to use checksums
f648b845dc15f7f25bc2cc9256b2986c206d8bd03f4fe2814489ec88317493f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py38-none-any.whl

Download URL scrapy_rss-1.1.0-py38-none-any.whl
Size 30.8 kB
Tags Python 3.8
SHA-256 checksum
How to use checksums
8a46f0954972c3d1ccc3d411ad70d17c8aa8fec2f521b7dacd0e1d852110e904
BLAKE2b-256 checksum
How to use checksums
b1fdeb89e2ab0304e9e703d9041cc79adbe2ce167b3bd295db0ca8f178bec9a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py37-none-any.whl

Download URL scrapy_rss-1.1.0-py37-none-any.whl
Size 30.8 kB
Tags Python 3.7
SHA-256 checksum
How to use checksums
148167dc8770dbbe6e0e46cadc12a22dae977b6740c42661f0cd8ffe7c5c95ce
BLAKE2b-256 checksum
How to use checksums
052b50ccb2f3372ad060c8cb0299a3ebca3781de9c70f9b50306053ad1903a14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py36-none-any.whl

Download URL scrapy_rss-1.1.0-py36-none-any.whl
Size 30.8 kB
Tags Python 3.6
SHA-256 checksum
How to use checksums
9db20209a8df29bcedfbacff501b62e5aba0fe090fac7eed3de7a962932e73c5
BLAKE2b-256 checksum
How to use checksums
8f1a8883412111d23ce74b25c21a17cd410b54f3c6d5612aa961eb0e38e389fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py35-none-any.whl

Download URL scrapy_rss-1.1.0-py35-none-any.whl
Size 30.8 kB
Tags Python 3.5
SHA-256 checksum
How to use checksums
93df81f54f940ffa2018dae55c7270e5eb9fa98eddf2473a6567ba9f19b8b654
BLAKE2b-256 checksum
How to use checksums
58e1b90f070a24c12e023b9a2777840025e69001367270da8cc052c6857fbc5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py34-none-any.whl

Download URL scrapy_rss-1.1.0-py34-none-any.whl
Size 30.8 kB
Tags Python 3.4
SHA-256 checksum
How to use checksums
efd65139722e08a7bb7b1f27f4ded658808c51522dbff8f76ff36ea3af806543
BLAKE2b-256 checksum
How to use checksums
2be69fd02ca9d1ffeca316948ac07ef044ffb4ad253f1bd4904e8fb7c2d25a21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py33-none-any.whl

Download URL scrapy_rss-1.1.0-py33-none-any.whl
Size 35.6 kB
Tags Python 3.3
SHA-256 checksum
How to use checksums
e367efe910cca18a8471453f30caabe41b76f1e48a5ce925b7c0c853fc773b16
BLAKE2b-256 checksum
How to use checksums
3d12458cfdbc5368a369e66a8fa9f32e80c368c0f29bc2b1bc1b2c3bdf4b58d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / scrapy_rss-1.1.0-py27-none-any.whl

Download URL scrapy_rss-1.1.0-py27-none-any.whl
Size 30.8 kB
Tags Python 2.7
SHA-256 checksum
How to use checksums
b42b69a77a77ff85f8c2b30ba2dd3e75c2929658b053357177bb5498bc2a97c5
BLAKE2b-256 checksum
How to use checksums
e9ade43a97a92ed69f72979d39673c45013a254c1f5208aff985fbf3bd3d3f1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Security for scrapy-rss 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page