X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=html2wiki%2Fhtml2wiki.py;fp=html2wiki%2Fhtml2wiki.py;h=d26c388be996825684e31ef326983f1dfb8aadb1;hb=063385f5e7c95c5f794ec39cc14857b8809a75a4;hp=0000000000000000000000000000000000000000;hpb=d4ee3f3304edf5267bfeb462f1e20e15fb79f7c3;p=otptools%2Fotptools.git diff --git a/html2wiki/html2wiki.py b/html2wiki/html2wiki.py new file mode 100755 index 0000000..d26c388 --- /dev/null +++ b/html2wiki/html2wiki.py @@ -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[^>]*?>.*?", re.S) +rex2 = re.compile(r"<\s*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