html转md脚本

2017-10-11  本文已影响0人  F4A3

使用了html2text这个包

import html2text
import os
import re
l = os.listdir(os.getcwd())
for file in l :
    if file.endswith('.html'):
        with open(file,'r',encoding='utf8') as f:
            md = html2text.html2text(f.read())
            pattern= r'-\n'
            md_text = re.sub(pattern, '-', md)
            with open(re.sub('html','md',file),'w',encoding='utf8') as nf:
                nf.write(md_text)
上一篇下一篇

猜你喜欢

热点阅读