Estoy haciendo un bot utilizando wininet, Lo que necesito es ver el contenido de un label de la web en un label en mi Form, actualmente hago esto:
Código
Option Explicit Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer Public Function GET_(hURL As String) As String Dim hBuffer As String * 1000 Dim hInternet As Long Dim hFile As Long Dim hRead As Long hInternet = InternetOpen(0, 1, vbNullString, vbNullString, 0): DoEvents If hInternet <> 0 Then hFile = InternetOpenUrl(hInternet, hURL, vbNullString, ByVal 0&, &H80000000, ByVal 0&): DoEvents If hFile <> 0 Then Do Call InternetReadFile(hFile, hBuffer, 1000, hRead): DoEvents GET_ = GET_ & Left$(hBuffer, hRead) If hRead = 0 Then Exit Do: DoEvents Loop End If End If If hInternet <> 0 Then Call InternetCloseHandle(hInternet) If hFile <> 0 Then Call InternetCloseHandle(hFile) End Function Public Function GetUserName(Optional ID As Long) As String Dim Buffer As String Dim UserName As String If ID > 0 Then MyProfileData = GET_(urlotroperfildemipagina & Str(ID)) Else MyProfileData = GET_(urlmiperfil) End If 'Buscamos "Ver perfil de " For x = 1 To Len(MyProfileData) Buffer = Mid(MyProfileData, x, 14) If Buffer = "Ver perfil de " Then Exit For Next 'Buscamos el nombre For x = x + 14 To Len(MyProfileData) Buffer = Mid(MyProfileData, x, 1) If Buffer <> Chr(34) Then UserName = UserName & Buffer Else Exit For Next GetUserName = UserName End Function
No estoy seguro de que sea una buena forma de hacerlo, por ello os pido consejo, asi como si en vez de wininet me recomendais otro metodo...
Gracias!