summaryrefslogtreecommitdiff
path: root/website/rss.py
blob: a5475672edcadf14e387edef3c9039999036a79d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import feedparser
import eventlet


with eventlet.Timeout(10):
    url = 'http://feeds.feedburner.com/PythonInsider/.rss'


def get_rss():

    feed = feedparser.parse(url)
    posts_to_show = []

    for post in feed.entries[0:4]:
        title = post.title
        link = post.link
        posts_to_show.append((title, link))
    if not posts_to_show:
        posts_to_show = [('Click here for latest news from python.org',
                               'https://pythoninsider.blogspot.com/')]
    return posts_to_show