0% found this document useful (0 votes)
20 views1 page

Leer Codigo HTML de Una Pagina Web

The document contains a Visual Basic script that uses the WinINet API to read the content of a specified URL. It defines functions to open an internet session, open a URL, read data from it, and close the internet handle. The function 'LeeURL' retrieves the content from 'http://www.vertutoriales.com' and assigns it to a text box named 'txtContenido'.

Uploaded by

Alfredo Oliveros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Leer Codigo HTML de Una Pagina Web

The document contains a Visual Basic script that uses the WinINet API to read the content of a specified URL. It defines functions to open an internet session, open a URL, read data from it, and close the internet handle. The function 'LeeURL' retrieves the content from 'http://www.vertutoriales.com' and assigns it to a text box named 'txtContenido'.

Uploaded by

Alfredo Oliveros
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1 Option Explicit

2 Public 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
3 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
4 Public Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal
sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
5 Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As
Integer
6
7 Public Const IF_FROM_CACHE = &H1000000
8 Public Const IF_MAKE_PERSISTENT = &H2000000
9 Public Const IF_NO_CACHE_WRITE = &H4000000
10
11 Public Const BUFFER_LEN = 256
12
13 'Funcion para leer
14
15 Public Function LeeURL(sURL As String) As String
16 Dim sBuffer As String * BUFFER_LEN, iResult As Integer, sData As String
17 Dim hInternet As Long, hSession As Long, lReturn As Long
18
19 'get the handle of the current internet connection
20 hSession = InternetOpen("vb wininet", 1, vbNullString, vbNullString, 0)
21 'get the handle of the url
22 If hSession Then hInternet = InternetOpenUrl(hSession, sURL, vbNullString, 0,
IF_NO_CACHE_WRITE, 0)
23 'if we have the handle, then start reading the web page
24 If hInternet Then
25 'get the first chunk & buffer it.
26 iResult = InternetReadFile(hInternet, sBuffer, BUFFER_LEN, lReturn)
27 sData = sBuffer
28 'if there’s more data then keep reading it into the buffer
29 Do While lReturn <> 0
30 iResult = InternetReadFile(hInternet, sBuffer, BUFFER_LEN, lReturn)
31 sData = sData + Mid(sBuffer, 1, lReturn)
32 Loop
33 End If
34
35 'close the URL
36 iResult = InternetCloseHandle(hInternet)
37
38 LeeURL = sData
39
40 End Function
41
42 'leyendo el contenido
43 txtContenido.Text = LeeURL("http://www.vertutoriales.com")

You might also like