• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 679
  • Last Modified:

Get HTML Source from WWW with VB6

 Hi Experts !

I need to open one HTML page via Internet and to get HTML source in string with VB6. Can you send me example how this can be done ???

 I prefer do not use any external control or DLL – because application already installed in about 70 PC in different towns. Computers worked with XP – so will be great if  DLL or OCX will be included in Win XP SP2

 I find a way with Microsoft Internet Control – but I don’t like that shdocvw.dll is 1.5 Mb and as I say I prefer to get solution without deploy file.
0
dvplayltd
Asked:
dvplayltd
1 Solution
 
bruintjeCommented:
Hi dvplayltd,
----------

wininet.dll is part of the OS so you are not really forced to deploy it with the app, but you can always do that to be sure

a sample + a class using the dll to retrieve html pages can be downloaded here
http://www.vbip.com/winsock/winsock_http_08_01.asp

----------
bruintje
share what you know, learn what you don't
0
 
Raynard7Commented:
Hi,

You should be able to use the below api and function to download from a given URL.  Depending if you are updating the data you may require the below DeleteUrlCacheEntry which deletes any previous chached entry for this url.

Once you have downloaded the file it is easy to then open it and extract any data as required.

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

Private Function DownloadFile(ByVal sURL As String, _
                             ByVal sLocalFile As String) As Boolean
   
   DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0)
   
End Function


****************************************************
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _
   Alias "DeleteUrlCacheEntryA" _
  (ByVal lpszUrlName As String) As Long
0
 
Ryan ChongCommented:
also:

Public Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long

'Get Status using using Microsoft XML 3.0 Object Library (MSXML)
Public Function getHTTPRequest_XML30(url As String) As String
    On Error GoTo EH
    DeleteUrlCacheEntry url
   
    Dim xmlHttp As MSXML2.XMLHTTP30
    Set xmlHttp = New MSXML2.XMLHTTP30
   
    xmlHttp.Open "GET", url, False
    xmlHttp.Send
    'Debug.Print xmlHttp.Status
    'Debug.Print xmlHttp.responseText
    getHTTPRequest_XML30 = xmlHttp.responseText
    Set xmlHttp = Nothing
    Exit Function
EH:
    Debug.Print Err.Number & ": " & Err.Description
    On Error Resume Next
    Set xmlHttp = Nothing
End Function

Hope this helps too, cheers
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now