|
@ -2,23 +2,24 @@ from feedparser import parse |
|
|
import random |
|
|
import random |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _parse_single_rss_feed(url): |
|
|
def _parse_single_rss_feed(url, entries): |
|
|
feed = parse(url) |
|
|
feed = parse(url) |
|
|
entries = {} |
|
|
entrylength = len(entries) |
|
|
for entrynumber, entry in enumerate(feed.entries): |
|
|
for entrynumber, entry in enumerate(feed.entries): |
|
|
if entry.has_key("title"): |
|
|
if entry.has_key("title"): |
|
|
entries[entry.title] = [] |
|
|
entries[entry.title] = [] |
|
|
entrylist = entries[entry.title] |
|
|
entrylist = entries[entry.title] |
|
|
else: |
|
|
else: |
|
|
title = str(entrynumber) |
|
|
title = str(entrynumber + entrylength) |
|
|
entries[title] = [] |
|
|
entries[title] = [] |
|
|
entrylist = entries[title] |
|
|
entrylist = entries[title] |
|
|
entrylist.append(entry.description) |
|
|
entrylist.append(entry.description) |
|
|
|
|
|
|
|
|
return entries |
|
|
return entries |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_rss_feeds(urls): |
|
|
def parse_rss_feeds(urls): |
|
|
entries = {} |
|
|
entries = {} |
|
|
for url in urls: |
|
|
for url in urls: |
|
|
entries.update(_parse_single_rss_feed(url)) |
|
|
entries = _parse_single_rss_feed(url, entries) |
|
|
return entries |
|
|
return entries |
|
|