# coding:utf-8
__author__ = 'Mr.数据杨'
__explain__ = '1.html文件转换MD文件'
import html2text as ht
def html_2_text(input_file, output_file):
text_maker = ht.HTML2Text()
# 读取html格式文件
with open(input_file, 'r', encoding='UTF-8') as f:
htmlpage = f.read()
# 处理html格式文件中的内容
text = text_maker.handle(htmlpage)
# 写入处理后的内容
with open(output_file, 'w', encoding='UTF-8') as f:
f.write(text)
if __name__ == "__main__":
input_file = "test.html"
output_file = "result.md"
html_2_text(input_file, output_file)
声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。