Skip to main content

Feedy

Simple RSS Feed Fetching Framework.

Tutorials

0. Installation

Supported python version is Python3.

pip install feedy

1. Getting feed entry’s title and link

Creating main.py like:

from feedy import Feedy

app = Feedy()

@app.add('https://www.djangopackages.com/feeds/packages/latest/rss/')
def djangopackages(feed_info, entry_info, body):
    """Get the latest django library information."""
    print("- [{pkgname}]({link})".format(pkgname=entry_info['title'], link=entry_info['link']))

if __name__ == '__main__':
    app.run()

And running:

$ python main.py
- [django-dynamic-views](http://www.djangopackages.com/packages/p/django-dynamic-views/)
- [django-simple-address](http://www.djangopackages.com/packages/p/django-simple-address/)
- [django-db-sanitizer](http://www.djangopackages.com/packages/p/django-db-sanitizer/)
:

2. Getting only newest feed entries

from feedy import Feedy

app = Feedy(store='feedy.dat', ignore_fetched=True)

@app.add('https://www.djangopackages.com/feeds/packages/latest/rss/')
def djangopackages(feed_info, entry_info, body):
    """Get the latest django library information."""
    print("- [{pkgname}]({link})".format(pkgname=entry_info['title'], link=entry_info['link']))

if __name__ == '__main__':
    app.run()

And running:

$ python main.py
- [django-dynamic-views](http://www.djangopackages.com/packages/p/django-dynamic-views/)
- [django-simple-address](http://www.djangopackages.com/packages/p/django-simple-address/)
- [django-db-sanitizer](http://www.djangopackages.com/packages/p/django-db-sanitizer/)
:
:
$ python main.py  # This is no output because There are no newest feed.
$

It displays only newest feed entries.

3. Add feed patterns

Add CNN news feed for collecting images on each articles.

from feedy import Feedy
from bs4 import BeautifulSoup  # You can select your favorite html parser.

app = Feedy(store='feedy.dat', ignore_fetched=True)

@app.add('http://rss.cnn.com/rss/edition.rss')
def cnn(feed_info, entry_info, body):
    soup = BeautifulSoup(body, "html.parser")
    for x in soup.find_all('img'):
        print(x['src'])

@app.add('https://www.djangopackages.com/feeds/packages/latest/rss/')
def djangopackages(feed_info, entry_info, body):
    """Get the latest django library information."""
    print("- [{pkgname}]({link})".format(pkgname=entry_info['title'], link=entry_info['link']))

if __name__ == '__main__':
    app.run()

And running:

$ python main.py
- [django-dynamic-views](http://www.djangopackages.com/packages/p/django-dynamic-views/)
- [django-simple-address](http://www.djangopackages.com/packages/p/django-simple-address/)
- [django-db-sanitizer](http://www.djangopackages.com/packages/p/django-db-sanitizer/)
:
:
http://i.cdn.turner.com/cnn/.e1mo/img/4.0/logos/menu_money.png
http://i.cdn.turner.com/cnn/.e1mo/img/4.0/logos/menu_style.png
http://edition.i.cdn.cnn.com/.a/1.269.4/assets/logo_cnn_nav_bottom.png
:
:

4. Command line interface

Feedy offers command line interface. It’s useful for debugging

help messages

$ feedy --help
Usage: feedy [OPTIONS] SRC OBJ

  Run your feedy's project flexibly.

Options:
  -v, --verbose                   Set log level
  -t, --targets TEXT              The target function names.
  -s, --store TEXT                A filename for store the last fetched time
                                  each RSS feed.
  -m, --max-entries INTEGER       The maximum length for fetching entries
                                  every RSS feed
  --ignore-fetched / --no-ignore-fetched
                                  The maximum length for fetching entries
                                  every RSS feed
  --help                          Show this message and exit.

If you want to get specified entry for debugging, please execute following command:

$ feedy main.py app --max-entries 2 --no-ignore-fetched
- [django-dynamic-views](http://www.djangopackages.com/packages/p/django-dynamic-views/)
- [django-simple-address](http://www.djangopackages.com/packages/p/django-simple-address/)
http://i.cdn.turner.com/cnn/.e1mo/img/4.0/logos/menu_money.png
http://i.cdn.turner.com/cnn/.e1mo/img/4.0/logos/menu_style.png

And if you want to run only a cnn function, please execute:

$ feedy main.py app --max-entries 2 --no-ignore-fetched --target cnn
http://i.cdn.turner.com/cnn/.e1mo/img/4.0/logos/menu_money.png
http://i.cdn.turner.com/cnn/.e1mo/img/4.0/logos/menu_style.png

After that, please execute a following command:

4. Use plugins

You can easy developing by using plugins. For example, you can get shared count in social sns like facebook and pocket. There are two ways for applying the plugin.

apply specified function using decorator

from feedy_plugins import social_share_plugin

@app.add('http://rss.cnn.com/rss/edition.rss')
@social_share_plugin
def cnn_shared(feed_info, entry_info, body, social_count):
    article = {
        'title': entry_info['title'],
        'pocket': social_count['pocket_count'],
        'facebook': social_count['facebook_count'],
    }
    print(article)

And running:

$ feedy main.py app -t cnn_shared -m 2
{'title': 'Searchers locate Flight 804, EgyptAir vice chairman says', 'pocket': 4, 'facebook': 25}
{'title': 'Security fears over French airports', 'pocket': 2, 'facebook': 9}

apply all functions with ``.install()``

from feedy import Feedy
from feedy_plugins import social_share_plugin
from bs4 import BeautifulSoup

app = Feedy(store='feedy.dat', ignore_fetched=True)
app.install(social_shared_plugin)  # apply each patterns.

@app.add('http://rss.cnn.com/rss/edition.rss')
def cnn_shared(feed_info, entry_info, body, social_count):
    article = {
        'title': entry_info['title'],
        'pocket': social_count['pocket_count'],
        'facebook': social_count['facebook_count'],
    }
    print(article)

@app.add('https://www.djangopackages.com/feeds/packages/latest/rss/', social_count)
def djangopackages(feed_info, entry_info, body, social_count):
    print("- [{pkgname}]({link})".format(pkgname=entry_info['title'], link=entry_info['link']))
    print(social_count['pocket_count'])

if __name__ == '__main__':
    app.run()

Create Plugins

To write a new plugin, simply create decorator like:

def social_share_plugin(callback):
    @wraps(callback)
    def wrapper(*args, **kwargs):
        additional_info = "This is custom plugin."
        kwargs['additional_info'] = additional_info
        callback(*args, **kwargs)
    return wrapper

Happy hacking :)

Resources

Release files for feedy 0.0.2

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

Source distribution (sdist)

Source distribution for feedy 0.0.2
File Size Uploaded
feedy-0.0.2.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for feedy 0.0.2
File Interpreter ABI Platform
feedy-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.2 kB

Release files / feedy-0.0.2.tar.gz

Download URL feedy-0.0.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6d023d5b6e0e777b0174cb3fe44f0623eb74b23db7091ffd6dfdc5919b9093b1
BLAKE2b-256 checksum
How to use checksums
c301908e7463827ca28510eabe101779da73ff5250ad68bc7f968d746bdbcc22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / feedy-0.0.2-py3-none-any.whl

Download URL feedy-0.0.2-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef17e2ad3cdd97ada1d366b44a6c454177f7715d69d02a18479bff14f48f6705
BLAKE2b-256 checksum
How to use checksums
a98662a0cad9e91f34f7636e5fd84e4671f9ce7669d4ad9145ad1fef5cb8d9df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.0.4

2 release files

0.0.3

2 release files

This release

0.0.2 This release

2 release files

0.0.1

2 release files

0.0.0

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