Save HTML content in webbrowser
The ipersist interface can be used to save HTML to a file. The implementation in VB and Delphi is as follows:
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.doc ument 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;
For the implementation method under VC, refer to this article by Jiang Sheng.Article:
Http://www.csdn.net/develop/read_article.asp? Id = 18465
In addition, ole_lib must be referenced for VB implementation.Http://www.applevb.com/lib/tl_ole.zipDownload