I'm very new to Feedparser and have returned to Python after a long break so would appreciate any help. I've tried the docs, which are very good, but I'm still slightly lagging.
How would I get Feedparser to take an rss feed and from that get the title and description of the first 10 items and label each item independently so that they can be inserted anywhere into other code? ie. I could just use the title of the first and second items with descriptions from others?
Hope that makes sense! Any help much appreciated
You start your program with importing the feedparser module. Create the feed. Put in the RSS feed that you want. The items are available in d.
Universal Feed Parser is a Python module for downloading and parsing syndicated feeds. It can handle RSS 0.90, Netscape RSS 0.91, Userland RSS 0.91, RSS 0.92, RSS 0.93, RSS 0.94, RSS 1.0, RSS 2.0, Atom 0.3, Atom 1.0, and CDF feeds.
The best method for installing FeedParser (or almost any Python package) is by using pip , Python's package manager. pip will be installed by default alongside Python as of Python 3.4 (and Python 2.7. 9).
import feedparser
f = feedparser.parse('http://domain/feed')
# f contains a dictionary key 'entries'
# entries is a list of dictionaries with 'title' and 'content' keys
for e in f['entries']:
print e.get('title', '')
print e.get('summary', '')
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With