help with RSS feeds

This is the place for queries that don't fit in any of the other categories.

help with RSS feeds

Postby yhmmc@yahoo.com » Tue Sep 24, 2013 7:00 pm

I get the error message:

##### here is the error message ##########
Code: Select all
File "qbo_rss_dev2.py", line 25, in <module>
fo.write( feed.entries[1].description);
IndexError: list index out of range


When i try to make an RSS feed reader for my robot.

My code is:

Code: Select all
#!/usr/bin/python
import feedparser
import subprocess
import sys


rss_url = "short-funny-jokes.com"
feed = feedparser.parse( rss_url )
posts = []
#encoding="iso-8859-1"

for i in range(1,len(feed['entries'])):
posts.append({
'title': feed['entries'][i].title,
'description': feed['entries'][i].summary,
'url': feed['entries'][i].link,
'content': feed['entries'][i].link,
})

#print feed.entries[1].title
# add a file to your directory and relist its path here
fo = open("http://www.jokesareawesome.com/rss/random/", "wb")
#fo.write( feed.entries[1].title);
fo.write(" ")
fo.write( feed.entries[1].description);
fo.close()
subprocess.call('echo ''|festival --tts qbo_rss.txt', shell=True)
subprocess.call('python qbo_rss_dev2.py', shell=True)


**Note: I have tried 20 different feeds and they all do the same thing.

Any body know what is going on? I am retired and just playing with Python and my robot. I wish for it to do RSS feeds and say the joke, etc.
Last edited by micseydel on Tue Sep 24, 2013 7:06 pm, edited 1 time in total.
Reason: Code tags, first post lock.
yhmmc@yahoo.com
 
Posts: 1
Joined: Tue Sep 24, 2013 6:58 pm

Re: help with RSS feeds

Postby ochichinyezaboombwa » Tue Sep 24, 2013 8:17 pm

what is len(feed['entries'])? Is there a reason for having "1" in range(1,len(feed['entries'])) ?
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm


Return to General Coding Help

Who is online

Users browsing this forum: metulburr and 1 guest