Save webpage using webbrowser control

。_饼干妹妹 提交于 2019-12-12 10:10:48

问题


I am using VB6 and the webbrowser control to navigate to to webpages. I want to save the pages I visit in regular intervals without any manual intervention.

I know how to parse HTML using DOM. But also need to save the pages without dispaling any dialog box.

Is this possible? Will appreciate some help.

Thanks. Tawfiq.


回答1:


This Microsoft KnowledgeBase article (Q244757) says there's no way to do this with the Web Browser control, but gives an alternative solution using UrlMon.dll, which I've put below.

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _ 
  "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _ 
  ByVal szFileName As String, ByVal dwReserved As Long, _ 
  ByVal lpfnCB As Long) As Long 

returnValue = URLDownloadToFile(0, "http://www.microsoft.com/ms.htm", _
  "c:\ms.htm", 0, 0) 

It won't download embedded content like images, apparently. UrlMon.dll requires Internet Explorer 3, so it is going to be available on any modern PC.

And for bonus marks, here's how to download multiple files asynchronously, in 100% native VB6, without no API calls at all!



来源:https://stackoverflow.com/questions/729355/save-webpage-using-webbrowser-control

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