All I need to do is download the text source of a webpage. I normally would use the inet control's OpenURL method for this, but I would like to do this in a reference-less project.
Is there an API way to do it?
Printable View
All I need to do is download the text source of a webpage. I normally would use the inet control's OpenURL method for this, but I would like to do this in a reference-less project.
Is there an API way to do it?
This is what I usually use,
URLText$ = GoWinInet("http://www.vbforums.com/")
btw, heres the URL to the flags and descriptions.
WinINet Constants - API Flags
you can also use the urldownloadtofile API
also pays to clear cachevb Code:
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 Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean Dim lngRetVal As Long lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0) If lngRetVal = 0 Then DownloadFile = True End Function
vb Code:
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _ Alias "DeleteUrlCacheEntryA" _ (ByVal lpszUrlName As String) As Long 'ensure this file does not exist in the cache Call DeleteUrlCacheEntry(sSourceUrl)
There is also VB's AsyncRead method, built into the runtime.
Search threads here and a sample in the CodeBank.
Quick and painless, and exactly what I was hoping for. Thanks much, guys.