aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-01-08 16:29:48 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-01-08 16:29:48 +0100
commitf4fdcb4adb3e346c42f3be1dcb60ce0a151b1b71 (patch)
tree84c9c0cf962f3ebe71e7232cb5ac4782f014f407
parent11d0608b6a8f1bdf8e3b1d2ddb67422fbdfb5f92 (diff)
downloaddisqus_xml2static_rst-f4fdcb4adb3e346c42f3be1dcb60ce0a151b1b71.tar.gz
Beginning of parsing, print only non-spam comments.
-rw-r--r--xml2static_rst.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/xml2static_rst.py b/xml2static_rst.py
index a4b0411..9bbe0d6 100644
--- a/xml2static_rst.py
+++ b/xml2static_rst.py
@@ -1,5 +1,17 @@
#!/usr/bin/python3
+import os.path
from xml.etree import ElementTree as ET
+ns = {'dflt': 'http://disqus.com',
+ 'xsi': 'http://disqus.com/disqus-internals',
+ 'dsq': 'http://www.w3.org/2001/XMLSchema-instance'}
+
tree = ET.parse("comments.xml")
+root = tree.getroot()
+for com_post in root.findall("dflt:post", ns):
+ if com_post.find('dflt:isSpam', ns).text == 'false':
+ print(ET.tostring(com_post, encoding='unicode', default_namespace=ns['dflt']))
+
+# if not os.path.exists('comments/'):
+# os.mkdir('comments')