ie批量保存网页为mht_使用Delphi将网页另存为HTML或MHT

ie批量保存网页为mht

When working with Delphi, the TWebBrowser component allows you to create a customized Web browsing application or to add Internet, file and network browsing, document viewing, and data downloading capabilities to your applications.

与Delphi一起使用时, TWebBrowser组件使您可以创建自定义的Web浏览应用程序,或为应用程序添加Internet,文件和网络浏览,文档查看和数据下载功能。

如何从TWebBrowser保存网页 ( How to Save a Web Page from TWebBrowser )

When using Internet Explorer, you are allowed you to view the source HTML code of a page and to save that page as a file on your local drive. If you are viewing a page that you wish to keep, go to the File/Save As ... menu item. In the dialog box that opens, you have several file types offered. Saving the page as a different filetype will affect how the page is saved.

使用Internet Explorer时,可以查看页面的源HTML代码,并将该页面另存为文件在本地驱动器上。 如果要查看要保留的页面,请转到“文件/另存为...”菜单项。 在打开的对话框中,提供了几种文件类型。 将页面另存为其他文件类型将影响页面的保存方式。

The TWebBrowser component (located on the "Internet" page of the Component Palette) provides access to the Web browser functionality from your Delphi applications. In general, you'll want to enable saving of a web page displayed inside a WebBrowser as an HTML file to a disk.

TWebBrowser组件(位于组件面板的“ Internet”页面上)使您可以从Delphi应用程序访问Web浏览器功能。 通常,您需要启用将WebBrowser内显示的网页作为HTML文件保存到磁盘的功能。

将网页另存为原始HTML ( Saving a Web Page As a Raw HTML )

If you only want to save a web page as a raw HTML you would select "Web Page, HTML only (*.htm, *.html)". It will simply save the current page's source HTML to your drive intact. This action will NOT save the graphics from the page or any other files used within the page, which means that if you loaded the file back from the local disk, you would see broken image links.

如果只想将网页另存为原始HTML,则可以选择“网页,仅HTML(* .htm,* .html)”。 它将简单地将当前页面的源HTML保存到驱动器中。 此操作不会保存该页面中的图形或该页面中使用的任何其他文件,这意味着,如果从本地磁盘重新加载文件,则会看到损坏的图像链接。

Here's how to save a web page as raw HTML using Delphi code:

这是使用Delphi代码将网页另存为原始HTML的方法:

Usage sample:

用法样本:

笔记 ( Notes)

  • The IPersistStreamInit and IStream interfaces are declared inside the ActiveX unit.

    IPersistStreamInit和IStream接口在ActiveX单元中声明。
  • The web page is saved as a raw HTML to the WebBrowser1.html file on the root folder of the C drive.

    该网页以原始HTML格式保存到C驱动器根文件夹下的WebBrowser1.html文件中。

MHT:Web存档,单个文件 ( MHT: Web Archive, Single File )

When you save a Web page as "Web archive, single file (*.mht)" the web document gets saved in the Multipurpose Internet Mail Extension HTML (MHTML) format with a .mht file extension. All relative links in the Web page are remapped and the embedded content is included in the .mht file, rather than being saved in a separate folder (as the case is with "Web Page, complete (*.htm, *.html)").

当您将网页另存为“ Web存档,单个文件(* .mht)”时,Web文档将以多用途Internet邮件扩展HTML(MHTML)格式保存,扩展名为.mht。 网页中的所有相对链接都被重新映射,并且嵌入的内容包含在.mht文件中,而不是保存在单独的文件夹中(视情况而定,“网页,完整(* .htm,* .html)”) )。

MHTML enables you to send and receive Web pages and other HTML documents using e-mail programs such as Microsoft Outlook, and Microsoft Outlook Express; or even your custom Delphi email sending solutions. MHTML enables you to embed images directly into the body of your e-mail messages rather than attaching them to the message.

MHTML使您能够使用电子邮件程序(例如Microsoft Outlook和Microsoft Outlook Express)发送和接收Web页和其他HTML文档。 甚至您的自定义Delphi电子邮件发送解决方案。 MHTML使您可以将图像直接嵌入到电子邮件正文中,而不是将其附加到邮件中。

Here's how to save a webpage as a single file (MHT format) using Delphi code:

以下是使用Delphi代码将网页另存为单个文件(MHT格式)的方法:

Sample usage:

用法示例:

注意 ( Note)

  • The _Stream class is defined in ADODB_TLB unit that you probably already have created. The IMessage and IConfiguration interfaces code from cdosys.dll library. CDO stands for Collaboration Data Objects - object libraries designed to enable SMTP Messaging.

    _Stream类在您可能已经创建的ADODB_TLB单元中定义。 IMessage和IConfiguration接口代码来自cdosys.dll库。 CDO代表协作数据对象-旨在启用SMTP消息传递的对象库。

The CDO_TLB is an auto-generated unit by Delphi. To create it, from the main menu select "Import Type Library", select "C:\WINDOWS\system32\cdosys.dll" then click the "Create unit" button.

CDO_TLB是Delphi自动生成的单元。 要创建它,请从主菜单中选择“导入类型库”,选择“ C:\ WINDOWS \ system32 \ cdosys.dll”,然后单击“创建单元”按钮。

没有TWebBrowser ( No TWebBrowser )

You could rewrite the WB_SaveAs_MHT procedure to accept an URL string (not TWebBrowser) to be able to save a web page directly -- no need to use the WebBrowser component. The URL from WebBrowser is retrieved using the WB.LocationURL property.

您可以重写WB_SaveAs_MHT过程以接受URL字符串(而不是TWebBrowser)以能够直接保存网页-无需使用WebBrowser组件。 使用WB.LocationURL属性检索来自WebBrowser的URL。

翻译自: https://www.thoughtco.com/save-a-web-page-as-html-or-mht-1058361

ie批量保存网页为mht

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值