import html2textdef html_to_markdown(html_file_path, md_file_path):"""参数:html_file_path (str): HTML 文件路径(如 "input.html")md_file_path (str): 输出 Markdown 文件路径(如 "output.md")"""with open(html_file_path, "r", encoding="utf-8") as f:html_content = f.read()converter = html2text.HTML2Text()converter.ignore_links = False converter.ignore_images = False converter.body_width = 0 converter.ul_item_mark = "-" converter.ol_item_mark = "." converter.em_symbol = "*" converter.strong_symbol = "**" markdown_content = converter.handle(html_content)with open(md_file_path, "w", encoding="utf-8") as f:f.write(markdown_content)print(f"转换成功!Markdown 文件保存至:{md_file_path}")html_input_path = "1.html" md_output_path = "1.md" html_to_markdown(html_input_path, md_output_path)