使用TWebBrowser组件保存网页为html和mht文件 收藏
使用TWebBrowser组件保存网页为html和mht文件 收藏
一、保存为HTML文件
uses ActiveX;
...
procedure WB_SaveAs_HTML(WB : TWebBrowser; const FileName : string) ;
var
PersistStream: IPersistStreamInit;
Stream: IStream;
FileStream: TFileStream;
begin
if not Assigned(WB.Document) then
begin
ShowMessage('Document not loaded!') ;
Exit;
end;
PersistStream := WB.Document as IPersistStreamInit;
FileStream := TFileStream.Create(FileName, fmCreate) ;
try
Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
if Failed(PersistStream.Save(Stream, True)) then ShowMessage('SaveAs HTML fail!') ;
finally
FileStream.Free;
end;
end; (* WB_SaveAs_HTML *)
使用方法:
WebBrowser1.Navigate('http://www.uufax.com') ;
//then save
WB_SaveAs_HTML(WebBrowser1,'c:\WebBrowser1.html') ;
二、另存为MHT单一文件
uses CDO_TLB, ADODB_TLB;
...
procedure WB_SaveAs_MHT(WB: TWebBrowser; FileName: TFileName) ;
var
Msg: IMessage;
Conf: IConfiguration;
Stream: _Stream;
URL : widestring;
begin
if not Assigned(WB.Document) then Exit;
URL := WB.LocationURL;
Msg := CoMessage.Create;
Conf := CoConfiguration.Create;
try
Msg.Configuration := Conf;
Msg.CreateMHTMLBody(URL, cdoSuppressAll, '', '') ;
Stream := Msg.GetStream;
Stream.SaveToFile(FileName, adSaveCreateOverWrite) ;
finally
Msg := nil;
Conf := nil;
Stream := nil;
end;
end; (* WB_SaveAs_MHT *)
使用方法:
//first navigate
WebBrowser1.Navigate('http://www.uufax.com') ;
//then save
WB_SaveAs_MHT(WebBrowser1,'c:\WebBrowser1.mht') ;
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/sunstone/archive/2009/11/09/4788743.a
相关文档:
看结论请直接看下面
今天写生成xml的php。没有用什么XMLDOMNode之类的来生成,而是直接echo出xml的内容。
xml的内容中有一部分的数据是从db中循环取出的,问题就出在这。我发现全部取出数据时,对于生成的xml,simplexml_load_string返回false,即表明生成的xml是非法的。
debug一下,发现取出数据加以限制 limit 8 一下 ......
HTML <noscript> 标签
定义和用法
noscript 元素用来定义在脚本未被执行时的替代内容(文本)。
此标签可被用于可识别 <script> 标签但无法支持其中的脚本的浏览器。
HTML 与 XHTML 之间的差异
NONE
提示和注释:
注释:如果浏览器支持脚本,那么它不会显示出 noscript 元素中的文本。
注释:无法识别 ......
.winstonDivClass{ overflow:hidden; zoom:1; }
如果父div需要根据子div的大小的变化而变化,那么这个父div
需要加上class="winstonDivClass"
,且该父div不能指定height属性,其中的子div的position属性最好为relative;
用zoom:1;触发ie的haslayout,用来清浮动
而overflow可以触发ie7的haslayout,并在FF ......
1)贴图:<img src="图片地址">
2)加入连接:<a href="所要连接的相关地址">写上你想写的字</a>
3)在新窗口打开连接:<a href="相关地址" target="_blank">写上要写的字</a>
消除连接的下划线在新窗口打开连接:
<a href="相关地址" style="text-decoration:none" target="_blank"> ......
<select name="CluefromType" id="CluefromType" style="width: 182px" onchange="return CluefromOtherTypeSelected();">
<option value="市场走访">
市场走访
< ......