Saving webpage content using webbrowser IHTMLDocument interface

跟風遠走 提交于 2020-01-06 06:24:09

问题


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.


回答1:


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 contains IHTMLStyleSheet elements, which in turn have a href-property which you can use to download the file. Scripts you can get via IHTMLDocument2::scripts which gives you a collection containing IHTMLScript elements, which have a src property. Same goes for images: use the src 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.



来源:https://stackoverflow.com/questions/1887179/saving-webpage-content-using-webbrowser-ihtmldocument-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!