OSDN Git Service

update html2fsjpwiki.py
[otptools/otptools.git] / html2wiki.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """Test suite for spyder.py."""
4
5 import sys
6 import os.path
7 import html2sfjpwiki
8 import re 
9
10 target = sys.argv[1]
11 fh = open(target, "r")
12 html = fh.read()
13 fh.close()
14
15 dir = os.path.dirname(target)
16 output = os.path.join(dir, "wiki.txt")
17
18 rex = re.compile(r"<\s*script[^>]*?>.*?</script>", re.S)
19 rex2 = re.compile(r"<\s*noscript[^>]*?>.*?</noscript>", re.S)
20 tmp = rex.sub("", html)
21 html_r = rex2.sub("", tmp)
22
23 c = html2sfjpwiki.Html2SfjpWiki()
24 r = c.parse(html_r, "article-body")
25
26 fh = open(output, "w")
27 fh.write(c.title + "\n\n")
28 fh.write(r)
29 fh.close()
30
31 #print r