Форум сайта python.su
Приветствую!
Оперирую таким способом - http://snipplr.com/view/16044/python-rss-feed-reader/, для примера беру http://lenta.ru/r/EX/import.xml :
import feedparser,sys
def f(data):
return data.encode("latin1","ignore")
try:
feed = sys.argv[1]
except IndexError:
feed = "http://lenta.ru/r/EX/import.xml"
d = feedparser.parse(feed)
#print f(d.feed.title),";",f(d.feed.link),";",f(d.feed.subtitle),";",f(d.version),";",f(d.encoding),";",len(d.entries)
for entry in d.entries:
print f(entry.title),";",
print f(entry.link),";",
try:
print f(entry.author_detail.name),";",
except AttributeError:
pass
try:
print f(entry.content)
except AttributeError:
pass
Офлайн