2010 1.09

From XPUB & Lens-Based wiki
Revision as of 23:13, 6 December 2010 by Michael Murtaugh (talk | contribs) (Created page with "== Read a feed with a URL from the command line == <source lang="python"> #!/usr/bin/env python import sys, feedparser try: url = sys.argv[1] except IndexError: url = "...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Read a feed with a URL from the command line

#!/usr/bin/env python
import sys, feedparser

try:
    url = sys.argv[1]
except IndexError:
    url = "http://feeds.bbci.co.uk/news/rss.xml"

feed = feedparser.parse(url)
for e in feed.entries:
    print e.title.encode("utf-8")