Dim CONTAR_LINEA As Integer = 0
Dim NOMBRE_1, NOMBRE_2, NOMBRE_3, NOMBRE_4, NOMBRE_5, NOMBRE_6, NOMBRE_7 As String
Dim web As WebBrowser 'Aquí se declara el WebBrowser
Private Sub CARGAR_PAGINA_INICIO()
web = New WebBrowser() ' Se instancia el WebBrower
web.ScriptErrorsSuppressed = True ' Oculta la ventana de errores si algún script de la página falló (de todas formas no los necesitamos)
web.Navigate(TextBoxURL.Text)
' Este Handler permite continuar con el proceso una vez que se ha cargado TODA la página (ya que si no ha cargado lanzará un error)
AddHandler web.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf OBTENER_DATOS)
End Sub
Public Sub OBTENER_DATOS()
Try
For Each ETIQUETA As HtmlElement In web.Document.All
If ETIQUETA.TagName = "TD" And ETIQUETA.GetAttribute("classname").Contains("card_n") Then
NOMBRE_1 = LTrim(ETIQUETA.InnerText)
ElseIf ETIQUETA.TagName = "SPAN" And ETIQUETA.GetAttribute("classname").Contains("timer") Then
NOMBRE_2 = LTrim(ETIQUETA.InnerText)
ElseIf ETIQUETA.TagName = "A" And ETIQUETA.GetAttribute("href").Contains("/t/") Then
NOMBRE_3 = LTrim(ETIQUETA.InnerText)
ElseIf ETIQUETA.TagName = "TD" And ETIQUETA.GetAttribute("classname").Contains("text-center") Then
NOMBRE_4 = LTrim(ETIQUETA.InnerHtml)
ElseIf ETIQUETA.TagName = "A" And ETIQUETA.GetAttribute("href").Contains("/r/") Then
NOMBRE_5 = LTrim(ETIQUETA.InnerText)
ElseIf ETIQUETA.TagName = "A" And ETIQUETA.GetAttribute("href").Contains("/t/") Then
NOMBRE_6 = LTrim(ETIQUETA.InnerText)
ElseIf ETIQUETA.TagName = "TD" And ETIQUETA.GetAttribute("classname").Contains("text-center") Then
NOMBRE_7 = LTrim(ETIQUETA.InnerText)
'PONER DATOSS QUE NOS INTERESA
DataGridView1.Rows.Add()
DataGridView1.Rows(CONTAR_LINEA).Cells(1).Value = NOMBRE_1
DataGridView1.Rows(CONTAR_LINEA).Cells(2).Value = NOMBRE_2
DataGridView1.Rows(CONTAR_LINEA).Cells(3).Value = NOMBRE_3
DataGridView1.Rows(CONTAR_LINEA).Cells(4).Value = NOMBRE_4
DataGridView1.Rows(CONTAR_LINEA).Cells(5).Value = NOMBRE_5
DataGridView1.Rows(CONTAR_LINEA).Cells(6).Value = NOMBRE_6
DataGridView1.Rows(CONTAR_LINEA).Cells(7).Value = NOMBRE_7
CONTAR_LINEA = CONTAR_LINEA + 1
ElseIf ETIQUETA.TagName = "A" And ETIQUETA.GetAttribute("href").Contains("contactus") Then
'ORDENAR DATA
DataGridView1.Sort(DataGridResultados.Columns(2), System.ComponentModel.ListSortDirection.Descending)
'QUITAR LA SELECCION DEL DATA
DataGridView1.ClearSelection()
Timer1.Start()
Exit Sub
End If
Next
Catch ex As Exception
My.Computer.Audio.Play(sonidoalerta & "Alerta.wav",
AudioPlayMode.WaitToComplete)
End Try
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'BORRA LA LISTA
REFRESCAR_LISTA()
web.Refresh()
OBTENER_DATOS()
End Sub
Private Sub REFRESCAR_LISTA()
Try
If DataGridView1.RowCount > 0 Then
web.Refresh()
DataGridView1.Rows.Clear()
End If
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub