by Alan Toews (6 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (52 Votes)
Nothing fancy about this, it simply retrieves the source of the url you specify. The best part about this code, is you don't need to add any controls to your code. you just drop in the module, and call one function
[some string]=GetURLSource("https://[some url]")
It's simple and lightweight, and with a little creativity, you could add features like daily news headlines, todays weather forecast, or stock prices to your projects.
If you'e got any questions, feel free to send me a message.
Inputs
url of web page
Assumes
assumes you are connected to the internet.
Code Returns
html source of web page
API DeclarationsPublic Declare Function InternetOpen
Lib "wininet.dll" Alias "InternetOpenA" (ByVal
sAgent As String, ByVal lAccessType As Long,
ByVal sProxyName As String, ByVal sProxyBypass As
String, ByVal lFlags As Long) As Long
Public Declare Function InternetOpenUrl _
Lib "wininet.dll" Alias "InternetOpenUrlA"(ByVal
hInternetSession As Long, ByVal sURL As String, _
ByVal sHeaders As String,ByVal lHeadersLength As _
Long, ByVal lFlags As Long, ByVal lContext As _
Long) As Long
Public Declare Function InternetReadFile _
Lib "wininet.dll" (ByVal hFile As Long, ByVal _
sBuffer As String,ByVal lNumBytesToRead As Long, _
lNumberOfBytesRead As Long) As Integer
Public Declare Function InternetCloseHandle _
Lib "wininet.dll" (ByVal hInet As Long) As Integer
Download Get webpage source through a simple api call (2 KB)