Save HTML content in webbrowser

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.