[英]Saving webpage content using webbrowser IHTMLDocument interface
We need to save the complete web page including img, javascript, css and html using ATL webbrowser (IHTMLDocument) control, 我们需要使用ATL webbrowser(IHTMLDocument)控件保存完整的网页,包括img,javascript,css和html,
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. 使用IHTMLDocument2 :: get_all()方法,我们已经保存了.html文件,但是现在我们如何获取诸如.css,javascript和图像文件之类的外部文件,请使用Internet Explorer或firefox用于本地保存网页的方法来帮助我们。
Thanks, Ramanand. 谢谢,拉曼南。
I think this will be a rather manual task: 我认为这将是一个相当手动的任务:
You can get a grip on the stylesheets by using the IHTMLDocument2::styleSheets
property. 您可以使用
IHTMLDocument2::styleSheets
属性来掌握样式表。 The collection contains IHTMLStyleSheet
elements, which in turn have a href
-property which you can use to download the file. 该集合包含
IHTMLStyleSheet
元素,这些元素又具有href
-property,可用于下载文件。 Scripts you can get via IHTMLDocument2::scripts
which gives you a collection containing IHTMLScript
elements, which have a src
property. 您可以通过
IHTMLDocument2::scripts
获得IHTMLDocument2::scripts
,该IHTMLDocument2::scripts
为您提供了包含IHTMLScript
元素的集合,这些元素具有src
属性。 Same goes for images: use the src
property to obtain a path. 图像也一样:使用
src
属性获取路径。 Somebody seems to do the same thing as you, have a look here . 似乎有人在做与您相同的事情, 在这里看看。 There are also some hints about handling relative pathes.
关于处理相对路径也有一些提示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.