-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path15-dataFeeds.py
More file actions
90 lines (67 loc) · 1.96 KB
/
15-dataFeeds.py
File metadata and controls
90 lines (67 loc) · 1.96 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import feedparser
import html2text
import numpy as np
import matplotlib.pyplot as plt
import time
# html to text parser
hp = html2text.HTML2Text()
hp.ignore_images = True
hp.ignore_emphasis = True
hp.ignore_links = True
#tazfeed = "http://www.taz.de/!s=rss/"
tazfeed = "http://taz.de/Themen-des-Tages/!p15;rss/"
stockfeed = "https://boerse.ard.de/index~rss.xml"
newsfeed = "http://www.tagesschau.de/xml/rss2"
ntvfeed = "https://www.n-tv.de/rss"
###################
# if pylab not present the comment the import and this function
def show(s):
plt.annotate(s, xy=(1, 1), xytext=(.96,.94), xycoords="data", textcoords="axes fraction",ha="right", va="top")
plt.axis('off')
plt.show()
###################
feed = feedparser.parse( tazfeed )
#print(feed)
print("----------------------------")
print("TAZ\n\n")
# show just 1 in a window
wincnt = 1
for e in feed.entries:
print(e.date, e.title)
for c in e.content:
if c.type == "text/html":
print(hp.handle(c.value))
if wincnt > 0:
show(hp.handle(c.value))
wincnt -= 1
print("\n\n")
#################
feed = feedparser.parse( stockfeed )
#print(feed)
print("----------------------------")
print("ARD Börse\n\n")
for e in feed.entries:
if hasattr(e,"summary"):
print(e.published,e.title)
print(hp.handle(e.summary))
print("\n\n")
#################
feed = feedparser.parse( newsfeed )
#print(feed)
print("----------------------------")
print("Tagesschau\n\n")
for e in feed.entries:
if hasattr(e,"summary"):
print(e.published,e.title)
print(hp.handle(e.summary))
print("\n\n")
#################
feed = feedparser.parse( ntvfeed )
#print(feed)
print("----------------------------")
print("NTV\n\n")
for e in feed.entries:
if hasattr(e,"summary"):
print(e.published,e.title)
print(hp.handle(e.summary))
print("\n\n")