Skip to content

Commit 98ce769

Browse files
committed
Added feed.py
1 parent 3f5cca1 commit 98ce769

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__/
2+
*.py[cod]

feed.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import feedparser
2+
3+
def parse(url):
4+
return feedparser.parse(url)
5+
6+
def get_source(parsed):
7+
feed = parsed['feed']
8+
return {
9+
'link': feed['link'],
10+
'title': feed['title'],
11+
'subtitle': feed['subtitle'],
12+
}
13+
14+
def get_articles(parsed):
15+
articles = []
16+
entries = parsed['entries']
17+
for entry in entries:
18+
articles.append({
19+
'id': entry['id'],
20+
'link': entry['link'],
21+
'title': entry['title'],
22+
'summary': entry['summary'],
23+
'published': entry['published_parsed'],
24+
})
25+
return articles

0 commit comments

Comments
 (0)