How to update the page of a site after changing the value of a field by VBA

1

Good evening.

I would like to know how I can update the page with the date that I reported by VBA. I put the date but the page does not change. Since you do not have a button, I do not know what to do.

Sub Links()

    Dim ie              As Object
    Dim tabela          As Object
    Dim Liga, DataHora  As String
    Dim Home, Away      As String
    Dim Link, data      As String
    Dim ResultadoFinal  As String
    Dim Posiz1, Posiz2  As Long
    Dim linha

    data = ThisWorkbook.Sheets("Plan1").Range("AD2")

    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True

    URL = "https://betsapi.com/cs/basketball/"
    ie.Navigate URL

    State = 0
    Do Until State = 4
        DoEvents
        State = ie.ReadyState
    Loop

    'até consigo mudar a data, mas ao mudar a data a pagina deveria se ajustar a essa data 
    '(como ocorre ao clicar de forma manual), mas isso não ocorre ao preencher pelo vba.
    ie.Document.forms.Item(1).Item(0).Value = Sheets("Plan1").Range("AD2") 'conte uma data. Ex: 2018-05-06

    Text1 = ie.Document.Body.innerHTML

    Text1 = Replace(Text1, "a href=/r/", "CJOS QUER ")


    'Coleta a parte importante dos links com base no meu marcador
    Posiz1 = 1
    i = 1
        Do
            On Error GoTo sai

            Posiz1 = InStr(Posiz1, Text1, "CJOS QUER ")

            Posiz1 = InStr(Posiz1, Text1, "CJOS QUER ") + 10
            Posiz2 = InStr(Posiz1, Text1, ">")

            Link = Trim(Mid(Text1, Posiz1, Posiz2 - Posiz1))
            c = InStr(1, Link, "/")
            Range("A" & i) = Left(Link, c - 1)
            Range("H" & i) = "https://betsapi.com/rs/bet365/" & Link
            Posiz1 = Posiz2 + 1
            i = i + 1
        Loop
sai:

    ie.Quit
    Set tabela = Nothing
    Set ie = Nothing

End Sub
    
asked by anonymous 11.05.2018 / 05:20

1 answer

1

Look at the solution I found. It's not elegant, but it's working (I do not know how long) ... If someone has a better idea, I'll accept it.

Sub Links()

    Dim ie              As Object
    Dim tabela          As Object
    Dim Liga, DataHora  As String
    Dim Home, Away      As String
    Dim Link, data      As String
    Dim ResultadoFinal  As String
    Dim Posiz1, Posiz2  As Long
    Dim linha

    data = ThisWorkbook.Sheets("Plan1").Range("AD2")

    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True

    'A data tem uma / no final. Ex: 2018-05-06/
    URL = "https://betsapi.com/cs/basketball/" & data
    ie.Navigate URL

    State = 0
    Do Until State = 4
        DoEvents
        State = ie.ReadyState
    Loop

    ie.Refresh
    Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 5)

    Text1 = ie.Document.Body.innerHTML

    Text1 = Replace(Text1, "a href=/r/", "CJOS QUER ")


    'Coleta a parte importante dos links com base no meu marcador
    Posiz1 = 1
    i = 1
        Do
            On Error GoTo sai

            Posiz1 = InStr(Posiz1, Text1, "CJOS QUER ")

            Posiz1 = InStr(Posiz1, Text1, "CJOS QUER ") + 10
            Posiz2 = InStr(Posiz1, Text1, ">")

            Link = Trim(Mid(Text1, Posiz1, Posiz2 - Posiz1))
            c = InStr(1, Link, "/")
            Range("A" & i) = Left(Link, c - 1)
            Range("H" & i) = "https://betsapi.com/rs/bet365/" & Link
            Posiz1 = Posiz2 + 1
            i = i + 1
        Loop

    sai:
    ie.Quit
    Set tabela = Nothing
    Set ie = Nothing

End Sub
    
11.05.2018 / 18:26