请教 有没有将 mhtml 转换为html 的工具

请教 有将 mhtml 转换为html 的工具

python手写一个。

以下perplexity实现:

import email
import os

def mhtml_to_html(mhtml_file, output_html_file):
    # 读取MHTML文件
    with open(mhtml_file, 'r', encoding='utf-8') as file:
        mhtml_content = file.read()

    # 解析MHTML内容
    msg = email.message_from_string(mhtml_content)
    html_content = ""
    
    # 提取HTML部分
    for part in msg.walk():
        if part.get_content_type() == 'text/html':
            html_content = part.get_payload(decode=True).decode('utf-8')
            break

    # 保存为HTML文件
    with open(output_html_file, 'w', encoding='utf-8') as output_file:
        output_file.write(html_content)

# 使用示例
mhtml_to_html('example.mhtml', 'output.html')
1 个赞

word
–打开mht文件–
–保存为html文件–

可以 转 exe 小程序吗