GroupDocs.Merger for Python via .NET allows you to combine multiple HTML files into a single document programmatically. All content — text, images, tables, embedded styles, and other markup — is preserved in the merged output.
HTML (HyperText Markup Language) is the standard language for web pages displayed in browsers. HTML 5, the latest version, offers broad flexibility for structuring and presenting content. HTML files can be served from a web server or loaded from the local file system.
Steps to merge HTML files
Create an instance of the Merger class and pass the path to the first (base) HTML file.
Call merger.join() with the path to each additional HTML file to append.
Call merger.save() with the desired output path to write the merged file.
fromgroupdocs.mergerimportMergerdefmerge_html_documents():# Load the first HTML file as the merge basewithMerger("./input.html")asmerger:# Append the second HTML filemerger.join("./input2.html")# Save the combined HTML filemerger.save("./output.html")if__name__=="__main__":merge_html_documents()
input.html is a sample file used in this example. Click here to download it.
input2.html is a sample file used in this example. Click here to download it.