idea to ghet value from web table

User avatar
sal21
PlatinumLounger
Posts: 4641
Joined: 26 Apr 2010, 17:36

idea to ghet value from web table

Post by sal21 »

Based the site:
https://www.oklotto.it/ambi-frequenti.php

how to get all value from table in square red?
tks
You do not have the required permissions to view the files attached to this post.

User avatar
SpeakEasy
5StarLounger
Posts: 775
Joined: 27 Jun 2021, 10:46

Re: idea to ghet value from web table

Post by SpeakEasy »

Doers not the response in your https://eileenslounge.com/viewtopic.php ... 4a798de8f7 give you a hint as to how you might do this?


One problem you will encounter is that this is a dynamic page, and so using MSXML2 library (which I suspect from your previous posts you are) won't really work, as it doesn't capture e.g tables injected by javascript.

So you'll need to use the ie library.

User avatar
sal21
PlatinumLounger
Posts: 4641
Joined: 26 Apr 2010, 17:36

Re: idea to ghet value from web table

Post by sal21 »

SpeakEasy wrote:
14 Apr 2025, 11:29
Doers not the response in your https://eileenslounge.com/viewtopic.php ... 4a798de8f7 give you a hint as to how you might do this?


One problem you will encounter is that this is a dynamic page, and so using MSXML2 library (which I suspect from your previous posts you are) won't really work, as it doesn't capture e.g tables injected by javascript.

So you'll need to use the ie library.
i bro... infact dont work with MSXML2

Have an idea with IE object?
Tks.

User avatar
SpeakEasy
5StarLounger
Posts: 775
Joined: 27 Jun 2021, 10:46

Re: idea to ghet value from web table

Post by SpeakEasy »

Code: Select all

Sub sppon2ie()
    Dim ie As Object
    Dim html As Object
    Dim mytable As Object
    Dim rowIndex As Long
    Dim colIndex As Long
     
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = False
    ie.Silent = True
    
    ie.navigate "https://www.oklotto.it/ambi-frequenti.php"
    
    Do While ie.Busy Or ie.readyState <> 4
        DoEvents
    Loop
    
    Set html = ie.document

    ' Now tables added via JavaScript are there
    Set mytable = html.getElementsByTagName("table")(3)
        For rowIndex = 0 To mytable.Rows.Length - 1
            For colIndex = 0 To mytable.Rows(rowIndex).Cells.Length - 1
                Debug.Print mytable.Rows(rowIndex).Cells(colIndex).innerText
            Next
        Next
    
    ' Clean up
    Set html = Nothing
    ie.Quit
    Set ie = Nothing
End Sub

User avatar
sal21
PlatinumLounger
Posts: 4641
Joined: 26 Apr 2010, 17:36

Re: idea to ghet value from web table

Post by sal21 »

SpeakEasy wrote:
14 Apr 2025, 16:58

Code: Select all

Sub sppon2ie()
    Dim ie As Object
    Dim html As Object
    Dim mytable As Object
    Dim rowIndex As Long
    Dim colIndex As Long
     
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = False
    ie.Silent = True
    
    ie.navigate "https://www.oklotto.it/ambi-frequenti.php"
    
    Do While ie.Busy Or ie.readyState <> 4
        DoEvents
    Loop
    
    Set html = ie.document

    ' Now tables added via JavaScript are there
    Set mytable = html.getElementsByTagName("table")(3)
        For rowIndex = 0 To mytable.Rows.Length - 1
            For colIndex = 0 To mytable.Rows(rowIndex).Cells.Length - 1
                Debug.Print mytable.Rows(rowIndex).Cells(colIndex).innerText
            Next
        Next
    
    ' Clean up
    Set html = Nothing
    ie.Quit
    Set ie = Nothing
End Sub
GREAT CODE BRO!

But based BARI, for example, i can get one to one the horizontal cells?

User avatar
SpeakEasy
5StarLounger
Posts: 775
Joined: 27 Jun 2021, 10:46

Re: idea to ghet value from web table

Post by SpeakEasy »

My code is an illustration of how to retrieve specific cells of an HTML table. You should now have all the information necessary to complete your task yourself.