Solved

Get HTML Source from WWW with VB6

Posted on 2006-07-01
3
633 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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WPF issue with Trigger 2 96
Can we place a tooltip on the actual vb6 form 5 36
Problem to page 4 75
Create Files based on Cell Values in a Range in Excel 12 21
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

863 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

26 Experts available now in Live!

Get 1:1 Help Now