CkPython
CkPython
Unpack an MHT Archive into Files
See more MHT / HTML Email Examples
Demonstrates Mht.UnpackMHT, which extracts an MHT archive into its constituent parts: the HTML document and its referenced resources.
The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background. The source may be an MHT file path or the literal MHT MIME text. The HTML is written under the chosen filename, and the referenced parts (images, style sheets, etc.) are written into a sub-directory.
Chilkat CkPython Downloads
import sys
import chilkat
success = False
mht = chilkat.CkMht()
# The file paths are relative to the application's current working directory. Absolute paths
# may also be used. Supply the paths appropriate to your own environment.
# Unpack an MHT file into its constituent parts. The 1st argument may be an MHT file path or the
# literal MHT MIME text. The 2nd argument is the directory to unpack into, the 3rd is the filename
# for the extracted HTML, and the 4th is the sub-directory (relative to the unpack directory) for the
# referenced parts such as images and style sheets.
success = mht.UnpackMHT("qa_data/page.mht","qa_output/unpacked","index.html","parts")
if (success == False):
print(mht.lastErrorText())
sys.exit()
print("MHT unpacked.")