使用网络浏览器 IHTMLDocument 接口保存网页内容
我们需要使用 ATL webbrowser (IHTMLDocument) 控件保存完整的网页,包括 img、javascript、css 和 html,
使用 IHTMLDocument2::get_all() 方法我们已经保存了 .html 文件,但现在我们如何获取外部文件,例如 .css 、javascript 和图像文件 请帮助我们了解 Internet Explorer 或 Firefox 用于在本地保存网页的方法。
谢谢, 拉马南德.
We need to save the complete web page including img, javascript, css and html using ATL webbrowser (IHTMLDocument) control,
using IHTMLDocument2::get_all() method we have saved .html file but now how do we get external files such as .css, javascript and image files
please help us with methods that internet explorer or firefox used to save the web page locally.
Thanks,
Ramanand.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这将是一项相当手动的任务:
您可以使用
IHTMLDocument2::styleSheets
属性来控制样式表。该集合包含IHTMLStyleSheet
元素,这些元素又具有可用于下载文件的href
属性。您可以通过IHTMLDocument2::scripts
获取脚本,它为您提供一个包含IHTMLScript
元素的集合,这些元素具有src
属性。图像也是如此:使用 src 属性获取路径。有人似乎做了和你一样的事情,看看 此处。还有一些关于处理相对路径的提示。I think this will be a rather manual task:
You can get a grip on the stylesheets by using the
IHTMLDocument2::styleSheets
property. The collection containsIHTMLStyleSheet
elements, which in turn have ahref
-property which you can use to download the file. Scripts you can get viaIHTMLDocument2::scripts
which gives you a collection containingIHTMLScript
elements, which have asrc
property. Same goes for images: use thesrc
property to obtain a path. Somebody seems to do the same thing as you, have a look here. There are also some hints about handling relative pathes.