My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
Tutorial  
Quick introduction to using feedformatter
featured
Updated Jun 9, 2009 by luke@maurits.id.au

Here's a super quick example to get you started. I'll try to expand on this somewhat soon.

from feedformatter import Feed
import time

# Create the feed
feed = Feed()

# Set the feed/channel level properties
feed.feed["title"] = "Example feed"
feed.feed["link"] = "http://www.example.com"
feed.feed["author"] = "Mr X. Ample"
feed.feed["description"] = "A simple example feed with one item in it"

# Create an item
item = {}
item["title"] = "Test item"
item["link"] = "http://www.example.com/example_url"
item["description"] = "And now for something completely different"
item["pubDate"] = time.localtime()
item["guid"] = "1234567890"

# Add item to feed
# You can do this as many times as you like with multiple items
feed.items.append(item)

# Print the feed to stdout in various formats
print feed.format_rss1_string()
print feed.format_rss2_string()
print feed.format_atom_string()

# Save the feed to a file in various formats
feed.format_rss1_file("example_feed_rss1.xml")
feed.format_rss2_file("example_feed_rss2.xml")
feed.format_atom_file("example_feed_atom.xml")
Comment by projet...@gmail.com, Jul 10, 2010

Very easy to use, I like it. Thanks a lot !

Is there a Python 3 version planned ?

Comment by project member luismarianoguerra@gmail.com, Jun 26, 2012

@projet...@gmail.com initial python 3 migration here: https://github.com/marianoguerra/feedformatter

Comment by echoqu...@gmail.com, Sep 17, 2013

Where is the documentation ?

Comment by riddhich...@gmail.com, Dec 30, 2014

Could you please explain the above code so it would be easier to understand?

Powered by Google Project Hosting