-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtofirebase.py
More file actions
51 lines (34 loc) · 1.14 KB
/
tofirebase.py
File metadata and controls
51 lines (34 loc) · 1.14 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 pyrebase
content = {}
feed = feedparser.parse('https://www.google.ca/alerts/feeds/00090353185029031169/16879600919504319759')
dt = datetime.fromtimestamp(mktime(feed.feed.updated_parsed))
print(feed.feed.title + " " + feed.feed.updated )
exit()
for key, value in feed.feed:
print(key)
exit()
config = {
#config properties go here
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
for entry in feed.entries:
a = {}
a['title'] = re.sub('<[^<]+?>', '', entry.title)
a['summary'] = re.sub('<[^<]+?>', '', entry.summary)
a['url'] = link = urllib.parse.unquote(entry.link[entry.link.find('url=')+4 : entry.link.find("&ct=")])
a['date'] = entry.published
try:
print('trying for this: ', link)
article = Article(link)
article.download()
article.parse()
a['text'] = article.text
a['image'] = article.top_image
content['articles/' + db.generate_key()] = a
except Exception as e:
print("SKIPPING: ", e)
pass
print("==============FINISHED===============")
pp.pprint(content)
#db.update(content)