-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathfinalTaskPart1.py
More file actions
50 lines (39 loc) · 1.65 KB
/
finalTaskPart1.py
File metadata and controls
50 lines (39 loc) · 1.65 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import feedparser
import argparse
import gc
version = 0.1
parser = argparse.ArgumentParser()
parser.add_argument("URL", help="This is the full adress of the rss feed.use ' ' ")
parser.add_argument("-l", "--lim", help="outputs the latest X(int)articles. can be run without lim to get all articles")
args = parser.parse_args()
limit=args.lim
def captureFeed(url):
feed = feedparser.parse(args.URL)
return feed
def standardOutput():
"""This is what happens when there are no tail commands added"""
feed = captureFeed(args.URL)
for article in feed.entries:
print("Title: ", article.title.replace("'", "'"), "\nDate: ",
article.published, "\nLinks: ", article.link, "\n")
def limitedOutput(limit):
"""This is what happens when there is only parameter on limmit"""
feed = captureFeed(args.URL)
for i in range(int(limit)):
T=feed.entries[i].title
P=feed.entries[i].published
L=feed.entries[i].link
print("Title: ", T.replace("'", "'"), "\nDate: ",
P, "\nLinks: ", L, "\n")
print("your limit was: ",limit)
if limit:
limitedOutput(limit)
else:
standardOutput()
"""
I have created the bare minimal working rss reader.
It has 2 parameters other than help. LIMIT and URL. i will include more as time progresses.
I need to remove logic from the global scope. i have done most of it but i want to use a class
for this,yet I dont know enough about them yet as I was ill on the date of the lecture and the powerpoint was complex for me at this stage
setuptools havent been made yet, Ill try to make them now
"""