保存webbrowser中的HTML内容

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 technofantasy 的 blog

保存webbrowser中的html内容

利用ipersist接口可以实现保存html到文件,在vb和delphi下的实现是这样的:

vb:

dim opf as ipersistfile
set opf = webbrowser1.document
opf.save "thefilenamehere.htm", false

delphi: 

uses
mshtml,olectrls, shdocvw, stdctrls,activex;
function gethtmlcode(wb: iwebbrowser2; acode: tstrings): boolean;
var
ps: ipersiststreaminit;
s: string;
ss: tstringstream;
sa: istream;
begin
ps := wb.document as ipersiststreaminit;
s := &&
ss := tstringstream.create(s);
try
sa:= tstreamadapter.create(ss, soreference) as istream;
result := succeeded(ps.save(sa, bool(true)));
if result then acode.add(ss.datastring);
finally
ss.free;
end;
end;

至于vc下的实现方法,可以参考蒋晟的这篇文章:
http://www.csdn.net/develop/read_article.asp?id=18465

另外vb地实现需要引用ole_lib,这个引用在 http://www.mvps.org/emorcillo/vb6/tlb/tl_ole.zip下载

本文关键:,webbrowser HTML vb Delphi 保存,
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top