OSDN Git Service

create html2wiki
[otptools/otptools.git] / html2wiki / html2wiki.py
diff --git a/html2wiki/html2wiki.py b/html2wiki/html2wiki.py
new file mode 100755 (executable)
index 0000000..d26c388
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""Test suite for spyder.py."""
+
+import sys
+import os.path
+import html2sfjpwiki
+import re 
+
+target = sys.argv[1]
+fh = open(target, "r")
+html = fh.read()
+fh.close()
+
+dir = os.path.dirname(target)
+output = os.path.join(dir, "wiki.txt")
+
+rex = re.compile(r"<\s*script[^>]*?>.*?</script>", re.S)
+rex2 = re.compile(r"<\s*noscript[^>]*?>.*?</noscript>", re.S)
+tmp = rex.sub("", html)
+html_r = rex2.sub("", tmp)
+
+c = html2sfjpwiki.Html2SfjpWiki()
+r = c.parse(html_r, "article-body")
+
+fh = open(output, "w")
+fh.write(c.title + "\n\n")
+fh.write(r)
+fh.close()
+
+#print r