Saving a Web Page Into A Single File
2007-04-05 08:54
351 查看
你是否曾经想过要把一个包含图片和文本的网页保存到单个的文件里?你可以使用IE的 saveAs 功能,但是缺点很明显,这个Saveas 对话框总是出于安全考虑而被show up.有重复杂的做法,可以避开 SaveAs 对话框。下面我给大家示范如何操作:
Do you ever want to save a web page into one single file, including pictures and text? You can use IE SaveAs command, but the drawback is obvious, the Save As dialog is always shown up for security reason. There is a complicated work around to avoid the Save As dialog (see Automated IE SaveAs MHTML). Here I show you an easy way to do it:
我们不提供例子程序,你可以把这段代码复制粘贴到你自己创建的程序中去。
Sample program is not provided, since you can create it on your own and copy & paste the above code snippet into your project.
Do you ever want to save a web page into one single file, including pictures and text? You can use IE SaveAs command, but the drawback is obvious, the Save As dialog is always shown up for security reason. There is a complicated work around to avoid the Save As dialog (see Automated IE SaveAs MHTML). Here I show you an easy way to do it:
#import "c:/program files/common files/system/ado/msado15.dll" _ no_namespace rename("EOF", "EndOfFile") #import no_namespace rename("EOF", "EndOfFile") ... void SaveWholePage(LPCTSTR page_url,LPCTSTR save_filename) { CoInitialize(NULL); { IMessagePtr iMsg(__uuidof(Message)); IConfigurationPtr iConf(__uuidof(Configuration)); iMsg->Configuration = iConf; try { iMsg->CreateMHTMLBody( page_url, cdoSuppressNone, "domain//username", "password"); } catch(_com_error err) { // handle exception } _StreamPtr pStream=iMsg->GetStream(); pStream->SaveToFile( save_filename, adSaveCreateOverWrite); } CoUninitialize(); }
简单的用法:
SaveWholePage("http://www.zaobao.com/gj/zg002_050203.html", "test.mht");
我们不提供例子程序,你可以把这段代码复制粘贴到你自己创建的程序中去。
Sample program is not provided, since you can create it on your own and copy & paste the above code snippet into your project.
相关文章推荐
- save a web page as a single file (mht format) using Delphi code
- download excel file from datagrid for webpage
- web.xml(7)_mime-mapping、welcome-file-list、error-page
- web.xml(7)_mime-mapping、welcome-file-list、error-page
- Single-file page & code-behind page
- Saving output of a grep into a file with colors
- How to Read XMLDocument into a SQL Sever XML field / saving XML to database or filesystem...best method?
- web.xml之welcome-file-list、error-page
- Saving a Canvas into a PNG file – WP8
- Web page construct -- Head first into HTML
- Getshell Via phpmyadmin SQL Execution In /import.php To Write Evil Webshell File Into Disk
- Single Page Application - 下一代的Web应用程序
- put applet into web page
- qibocms /hr/listperson.php File Arbitrarily Include Vul Via Variable Uninitialization && Front Page Upload WEBSHELL
- axis2 File "/axis2-web/listSingleService.jsp" not found
- 发布webservice接口时报错-HTTP Status 500 - File "/axis2-web/listSingleService.jsp" not found
- axis2异常:File "/axis2-web/listSingleService.jsp" not found 的处理
- Loads the local HTML file into the web view in the app
- WebView中删除JS中confirm框上的The page at "file".....
- Top 10 Ways to Trick Yourself into Saving Money