Solved

Get HTML Source from WWW with VB6

Posted on 2006-07-01
3
646 Views
Last Modified: 2013-11-13
 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
Comment
Question by:dvplayltd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 17023422
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
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17023427
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
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 17023504
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question