I wrote my own feed reader using feedparser.py but it takes about 14
seconds to process 7 feeds (on a windows box), which seems slow on my
DSL line. Does anyone see how I can optimize the script below? Thanks
in advance, Bill
# UTF-8
import feedparser
rss = [
'http://feeds.feedburne r.com/typepad/alleyinsider/
silicon_alley_i nsider',
'http://www.techmeme.co m/index.xml',
'http://feeds.feedburne r.com/slate-97504',
'http://rss.cnn.com/rss/money_mostpopul ar.rss',
'http://rss.news.yahoo. com/rss/tech',
'http://www.aldaily.com/rss/rss.xml',
'http://ezralevant.com/atom.xml'
]
s = '<html>\n<head> \n<title>C:/x/test.htm</title>\n'
s += '<style>\n'\
'h3{margin:10px 0 0 0;padding:0}\n' \
'a.x{color:blac k}'\
'p{margin:5px 0 0 0;padding:0}'\
'</style>\n'
s += '</head>\n<body>\n <br />\n'
for url in rss:
d = feedparser.pars e(url)
title = d.feed.title
link = d.feed.link
s += '\n<h3><a href="'+ link +'" class="x">'+ title +'</a></h3>\n'
# aldaily.com has weird feed
if link.find('alda ily.com') != -1:
description = d.entries[0].description
s += description + '\n'
for x in range(0,3):
if link.find('alda ily.com') != -1:
continue
title = d.entries[x].title
link = d.entries[x].link
s += '<a href="'+ link +'">'+ title +'</a><br />\n'
s += '<br /><br />\n</body>\n</html>'
f = open('c:/scripts/myFeeds.htm', 'w')
f.write(s)
f.close
print
print 'myFeeds.htm written'
seconds to process 7 feeds (on a windows box), which seems slow on my
DSL line. Does anyone see how I can optimize the script below? Thanks
in advance, Bill
# UTF-8
import feedparser
rss = [
'http://feeds.feedburne r.com/typepad/alleyinsider/
silicon_alley_i nsider',
'http://www.techmeme.co m/index.xml',
'http://feeds.feedburne r.com/slate-97504',
'http://rss.cnn.com/rss/money_mostpopul ar.rss',
'http://rss.news.yahoo. com/rss/tech',
'http://www.aldaily.com/rss/rss.xml',
'http://ezralevant.com/atom.xml'
]
s = '<html>\n<head> \n<title>C:/x/test.htm</title>\n'
s += '<style>\n'\
'h3{margin:10px 0 0 0;padding:0}\n' \
'a.x{color:blac k}'\
'p{margin:5px 0 0 0;padding:0}'\
'</style>\n'
s += '</head>\n<body>\n <br />\n'
for url in rss:
d = feedparser.pars e(url)
title = d.feed.title
link = d.feed.link
s += '\n<h3><a href="'+ link +'" class="x">'+ title +'</a></h3>\n'
# aldaily.com has weird feed
if link.find('alda ily.com') != -1:
description = d.entries[0].description
s += description + '\n'
for x in range(0,3):
if link.find('alda ily.com') != -1:
continue
title = d.entries[x].title
link = d.entries[x].link
s += '<a href="'+ link +'">'+ title +'</a><br />\n'
s += '<br /><br />\n</body>\n</html>'
f = open('c:/scripts/myFeeds.htm', 'w')
f.write(s)
f.close
print 'myFeeds.htm written'
Comment