Extracting images and text from an mht file

允我心安 提交于 2019-12-09 16:39:14

问题


I have a mht file that contains images and some text. When I open it with notepad++, I see xml and then illegible text which I think are images. Can somebody tell me how can I extract images and text from an mht file using a java program? Thanks.


回答1:



try the tool called ExtractMHT
http://www.legroom.net/software/extractmht




回答2:


It's a bit old, but Open it in Internet Explorer, and save as HTML also do the job

Update:

If you open the .mht file in IE, then save it, with the "Save as type" set to "Webpage, complete (.htm;.html)", then it will create the 'filename.htm' file, as well as a 'filename_files' directory. In that directory will be a lot of .tmp files. For output from the MS "Problem Steps Recorder", these will include among them a bunch of files with '(1)' in the name (as in there might be a 'mhtD3B8.tmp' file as well as a 'mhtD3B8(1).tmp' file). The '(1)' files are the images, in .jpg format, simply with a .tmp extension. Search for all the files with '(1)' in the name from that folder, and copy them to a different directory.

Once in the new directory, open a cmd window pointed there. To change all the extensions at once, type "rename *.tmp *.jpg" (without the quotes) and press Enter. Voila - all the image files are extracted.

As for accessing the text - since the file is now saved as a .htm file, you should be able to open that file in Notepad++ and parse/read it properly there.

Hope this helps!




回答3:


There's an open-source perl tool called unmht which should do the job:

The first HTML file in the archive is taken to be the primary web page, the other contained files for "page requisites" such as images or frames. The primary web page is written to the output directory (the current directory by default), the requisites to a subdirectory named after the primary HTML file name without extension, with "_files" appended. Link URLs in all HTML files referring to requisites are rewritten to point to the saved files.



来源:https://stackoverflow.com/questions/20476678/extracting-images-and-text-from-an-mht-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!