Solved

Get HTML Source from WWW with VB6

Posted on 2006-07-01
3
630 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
3 Comments
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
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
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now