save a web page as a single file (mht format) using Delphi code
Here's how to save a web page as a single file (mht format) using Delphi code:
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 *)
Sample usage:
//first navigate
WebBrowser1.Navigate('http://delphi.about.com');
//then save
WB_SaveAs_MHT(WebBrowser1,'c:\WebBrowser1.mht');
Note 1: 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.
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.
资料引用:http://www.knowsky.com/336151.html
save a web page as a single file (mht format) using Delphi code的更多相关文章
- [Project] Simulate HTTP Post Request to obtain data from Web Page by using Python Scrapy Framework
1. Background Though it's always difficult to give child a perfect name, parent never give up trying ...
- Lesson 2 Building your first web page: Part 3
Time to build your first HTML page by hand I could go on with more theory and send half of you to sl ...
- Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques
Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques Jan 04, 2017, Vers ...
- [转]Calling Web Service Functions Asynchronously from a Web Page 异步调用WebServices
本文转自:http://www.codeproject.com/Articles/70441/Calling-Web-Service-Functions-Asynchronously-from Ove ...
- Tutorial: Importing and analyzing data from a Web Page using Power BI Desktop
In this tutorial, you will learn how to import a table of data from a Web page and create a report t ...
- Android WebView常见问题的解决方案总结----例如Web page not available
之前android虚拟机一直都可以直接联网,今天写了一个WebView之后,突然报出了Web page not available的错误,但是查看虚拟机自带的浏览器,是可以上网的,所以检查还是代码的问 ...
- how to export svg form web page in js
how to export svg form web page in js https://stackoverflow.com/questions/2483919/how-to-save-svg-ca ...
- 解读Web Page Diagnostics网页细分图
解读Web Page Diagnostics网页细分图 http://blog.sina.com.cn/s/blog_62b8fc330100red5.html Web Page Diagnostic ...
- 网页细分图结果分析(Web Page Diagnostics)
Discuz开源论坛网页细分图结果分析(Web Page Diagnostics) 续LR实战之Discuz开源论坛项目,之前一直是创建虚拟用户脚本(Virtual User Generator)和场 ...
随机推荐
- sublime text 格式化html css 与显示函数列表
sublime 格式化html css 1.ctrl + shift + p 2.输入install package,选择install package 3.输入:HTML-CSS-JS Pretti ...
- 【转】【CTO俱乐部走进支付宝】探索支付宝背后的那些技术 部分
怎么避免研发环节当中引入漏洞?“我们有一套比较成熟的安全研发开发框架.首先我们用统一的框架,框架本身是经过我们安全工程师去做过非常好的认证的,同时在研发过程当中我们对这些问题也有些规范.一旦发现风险我 ...
- iOS开发中“此证书的签发者无效”的解决方式
iOS开发过程中有时候会出现证书所有变成无效,例如以下图 然后进行打包的时候会提演示样例如以下警告: 解决方法: 第一步: 下载https://developer.apple.com/certif ...
- Torch-RNN运行过程中的坑 [2](Lua的string sub函数,读取中文失败,乱码?)
0.踩坑背景 仍然是torch-rnn/LanguageModel.lua文件中的一些问题,仍然是这个狗血的LM:encode_string函数: function LM:encode_string( ...
- Chrome浏览器快捷键(收藏!)
- 我如何让echarts实现了分组(原创插件echarts.group代码分享)
前言 echarts是百度出品的一款很棒的前端图表控件,被评为“百度少有的良心产品”.可以实现散点图.折线图.柱状图.地图.饼图.雷达图.K线图等等几十种常用.不常用的图表,效果酷炫. 示例地址:ht ...
- 第七篇:使用 fcntl 函数 获取,设置文件的状态标志
前言 当打开一个文件的时候,我们需要指定打开文件的模式( 只读,只写等 ).那么在程序中如何获取,修改这个文件的状态标志呢? 本文将告诉你如何用 fcntl函数 获取指定文件的状态标志. 解决思路 1 ...
- python 之 多进程
阅读目录 1. Process 2. Lock 3. Semaphore 4. Event 5. Queue 6. Pipe 7. Pool 序. multiprocessingpython中的多线程 ...
- 【Redis】redis分页查询理解
偶然在代码中发现一个接口,接口定义说是分页查询,但逻辑实现是Redis.不太理解,Redis怎么分页?后来看到一篇文章,然后了解了. 1.Zrevrange实现 通过SortedSet的zrevran ...
- Java模拟并发
=========================one============================= public class Bingfa { public static void m ...