def getNewsFeed(self):
# parse the feed and get the result in res
res = feedparser.parse(self.rssFeedUrl)
# get the total number of entries returned
resCount = len(res.entries)
# exit out if empty
if resCount == 0:
return ""
# if the resCount is less than the feedCount specified cap the feedCount to the resCount
if resCount < self.feedCount:
self.feedCount = resCount
# create empty array
resultList = []
# loop from 0 to feedCount so we append the right number of entries to the return list
for x in range(0, self.feedCount):
resultList.append(res.entries[x])
return resultList
评论列表
文章目录