-
Notifications
You must be signed in to change notification settings - Fork 1
/
rss.py
29 lines (26 loc) · 850 Bytes
/
rss.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import datetime
from rfeed import *
from dateutil.parser import parse
def get_rss_for_json(data):
items = []
for article in data['articles']:
pubDate = datetime.datetime.now()
try:
pubDate = parse(article['publishedAt'])
except:
pass
item = Item(
title = article['title'],
link = article['url'],
description = article['description'],
author = article['author'],
guid = Guid(article['url']),
pubDate = pubDate)
items.append(item)
feed = Feed(title = "Newsapi RSS Feed",
link = "https://newsapi.org",
description = "Newsapi",
language = "en-US",
lastBuildDate = datetime.datetime.now(),
items = items)
return feed.rss()