Solved

Get HTML Source from WWW with VB6

Posted on 2006-07-01
3
635 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
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 50

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

813 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

11 Experts available now in Live!

Get 1:1 Help Now