-
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathshow_sample_entry.py
More file actions
executable file
·27 lines (24 loc) · 907 Bytes
/
show_sample_entry.py
File metadata and controls
executable file
·27 lines (24 loc) · 907 Bytes
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
#!/usr/bin/env python3
# Copyright (c) 2016-2017 Eric Eisenhart
# This software is released under an MIT-style license.
# See LICENSE.md for full details.
import pprint
import sys
import feedparser
# feedparser.PREFERRED_XML_PARSERS.remove("drv_libxml2")
feedparser.USER_AGENT = "linux:github.com/freiheit/discord_feedbot:show_sample_entry.py (by /u/freiheit)"
# 0 is command itself:
if len(sys.argv) == 2:
feed_url = sys.argv[1]
feed_data = feedparser.parse(feed_url)
pp = pprint.PrettyPrinter(indent=4, depth=1)
print("# We currently restrict this output to depth=1,")
print("# because that's all the bot can currently handle.")
print(
"# So, ignore those `[...]` and `{...}` structures and only look at 'strings'."
)
pp.pprint(feed_data.entries[0])
else:
print(
"Give me 1 feed URL on the command-line, and I'll give the first entry from it."
)