2023-06-03 18:12:55 +02:00
|
|
|
from feedparser import parse
|
|
|
|
import random
|
|
|
|
|
2023-06-03 19:27:41 +02:00
|
|
|
|
2023-06-03 18:12:55 +02:00
|
|
|
def _parse_single_rss_feed(url):
|
|
|
|
feed = parse(url)
|
|
|
|
entries = {}
|
|
|
|
for entrynumber, entry in enumerate(feed.entries):
|
|
|
|
if entry.has_key("title"):
|
|
|
|
entries[entry.title] = []
|
|
|
|
entrylist = entries[entry.title]
|
|
|
|
else:
|
|
|
|
title = str(entrynumber)
|
|
|
|
entries[title] = []
|
|
|
|
entrylist = entries[title]
|
|
|
|
entrylist.append(entry.description)
|
|
|
|
return entries
|
|
|
|
|
2023-06-03 19:27:41 +02:00
|
|
|
|
2023-06-03 18:12:55 +02:00
|
|
|
def parse_rss_feeds(urls):
|
|
|
|
entries = {}
|
|
|
|
for url in urls:
|
|
|
|
entries.update(_parse_single_rss_feed(url))
|
|
|
|
return entries
|