How to obtain data from a website withExcel

0

It turns out that I need to obtain the data from an excel page, I could already do the first part that was to send the data to consult the page with excel vba the code I used was this:

Sub obtenerDatos()
    Dim IE As InternetExplorer
    Dim i As Long
    Dim url, captcha As String
    Dim objCollection As Object
    Dim objCollection1 As Object
    url = "https://consulta.simit.org.co/Simit/verificar/contenido_verificar_pago_linea.jsp"
    Set IE = New InternetExplorer
    IE.Visible = True
    IE.Navigate url
    While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Wend
    Set objCollection = IE.Document.getElementsByTagName("input")
    
    For i = 2 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
        objCollection(9).Value = 72222982 'Sheets("CONDUCTOR").Cells(i, 1).Value
        captcha = objCollection(14).Value
        objCollection(15).Value = captcha
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{TAB}"
        Application.Wait (Now + TimeValue("0:00:01"))
        SendKeys "{ENTER}"
        Application.Wait (Now + TimeValue("0:00:02"))
        Set objCollection1 = IE.Document.getElementsByTagName("div")
        objCollection1.Length
        If objCollection1 Is Nothing Then
            Sheets("CONDUCTOR").Cells(i, 14).Value = 0
        Else
        
       End If
    Next
End Sub

This part is where I have problems.

Set objCollection1 = IE.Document.getElementsByTagName("div")
    objCollection1.Length
    If objCollection1 Is Nothing Then
        Sheets("CONDUCTOR").Cells(i, 14).Value = 0
    Else

   End If

It turns out that once you validate the ID and captcha that you sent by excel it loads another page with the requested data, but now what I need is to go through the page that loads me to know if any div or not to fill my form in excel.

This is what I do because I have more than 100 cards and validating one by one takes away a lot of time.

I appreciate the help you can give me.

    
asked by Familia Valencia Hdz 21.11.2018 в 20:54
source

0 answers