返回信息流rt。mht文件格式好像不公开的样子,这个有人玩过吗?
这是一条镜像帖。来源:北邮人论坛 / soft-design / #26117同步于 2008/6/5
该镜像源已超过 30 天没有更新,可能在源站已被删除。
SoftDesign机器人发帖
请教mht文件怎么转换成html文件?
jingang1016
2008/6/5镜像同步6 回复
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
以前收集到的一个perl脚本...恩...
#!/usr/bin/perl
use MIME::Base64;
#Set the file
$FileName = @ARGV[0];
#Read in the file & Strip \r
open(FILE, $FileName);
while($file_line = <FILE>){
$file_line =~ s/\r\n/\n/;
$file_contents .= $file_line;
}
close(FILE);
#Check for file
if(!$file_contents){
print "Usage: mht2html.pl FILENAME - converts Microsoft MHT files to the h
tml equivalent";
exit;
}
#Parse out the MIME sections in the file
while($file_contents =~ /------=_NextPart(.*?)\n------=_NextPart/sg){
$mime_section = $1;
#Parse out the filename and content
$mime_section =~ /Content-Location(.*)\/(.*?)\nContent/sg;
$file_name = $2;
$mime_section =~ /Content-Type(.*?)\n\n(.*)\n/sg;
$content = $2;
#Check for base64
if($mime_section =~ /base64/){
$content = decode_base64($content);
}else{
#Strip the MS garbage from the file
$content =~ s/<!--\[(.*?)\]>(.*?)<!\[endif\]-->//sig;
$content =~ s/<!\[(.*?)\]>//sig;
$content =~ s/=3D/=/g;
$content =~ s/=\n//gm;
$content =~ s/src="(.*?)\/(.*?)"/src="$2"/sig;
}
#Write the new file
open(FILE, ">$file_name");
print FILE $content;
close(FILE);
}
【 在 jingang1016 (哈哈) 的大作中提到: 】
: rt。mht文件格式好像不公开的样子,这个有人玩过吗?
【 在 atian25 的大作中提到: 】
: MHT是HTML+资源文件吧.
: 这些资源文件在里面是怎么存的?跟LINK有关?
: 我发现有些MHT存下来后断网就不能看了.
和HTTP报文差不多
有一个头部,其中一个字段是指明一个随机串作边界
后面由那个边界把mht划分为若干部分,每个边界占单独一行,每一部分都是一个资源,把html以及相关资源都保存进来
每部分都有一个头部,指明格式、传输编码和资源文件名,两个回车换行(CRLF * 2)后就是资源正文,根据前面的编码按字节保存