-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.py.bak
60 lines (50 loc) · 1.41 KB
/
app.py.bak
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
51
52
53
54
55
56
57
58
59
60
import sys
import feedparser
import colorama
from colorama import init
from colorama import Fore, Back, Style
init(autoreset=True)
#print(Fore.RED + 'some red text')
#print('automatically back to default color again')
url = sys.argv[1]
def parse(url):
d = feedparser.parse(url)
feed_title = d.feed.title
feed_link = d.feed.link
feed_desc = d.feed.description
feed_date = d.feed.updated
#print d
#print feed_date
print d['entries'][1]['title']
#show(feed_title,feed_link,feed_desc)
def latest():
d = feedparser.parse(url)
print (Back.RED + "Title:") + (Style.RESET_ALL + " " + d.entries[0].title)
print (Back.YELLOW + "Link:") + (Style.RESET_ALL + " " + d.entries[0].link)
def latest_five():
d = feedparser.parse(url)
i=0
for i in range(0,5):
print (Back.CYAN + "\t" + str(i+1) + "\t")
print (Back.RED + "Title:") + (Style.RESET_ALL + " " + d.entries[i].title)
print (Back.YELLOW + "Link:") + (Style.RESET_ALL + " " + d.entries[i].link)
#print "Content: " + d.entries[i]['content']
def show(title,link,desc):
print str(title)
#print str(date)
print str(link)
print str(desc)
def menu():
print """What do you wish to do now? \n1. Read the latest issue.\n2. Get the titles of the latest 5 issues."""
opt = int(raw_input('opt: '))
if opt==1:
latest()
elif opt==2:
latest_five()
else:
print "Not a valid choice"
exit(0)
if __name__== "__main__":
#parse(sys.argv[1])
url = sys.argv[1]
menu()