• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Receiving data from a website with Excel VBA

Try this script. It should fetch you the data populated upon pressing the "Galopları" tab:

Code:
Sub GetData()
    Dim elem As Object, trow As Object
    Dim R&, C&, S$

    With New XMLHTTP60
        .Open "POST", "https://yenibeygir.com/at/getatdetaytab", False
        .setRequestHeader "content-type", "application/x-www-form-urlencoded; charset=UTF-8"
        .send "tab=galopTab&id=15673"
        S = .responseText
    End With

    With New HTMLDocument
        .body.innerHTML = S

        For Each elem In .getElementsByClassName("at_Galoplar")(0).Rows
            For Each trow In elem.Cells
                C = C + 1: Cells(R + 1, C) = trow.innerText
            Next trow
            C = 0: R = R + 1
        Next elem
    End With
End Sub

Make sure to add the following libraries before execution:

Code:
Microsoft Html Object Library
Microsoft xml, v6.0
 
Last edited:
Dear Shahin
This has been super. Thanks. Thanks for your effort.
The code is working but there are a few problems.
What do I do if I want to receive the data with the link?
Can I adapt this code to another web page ("Son 1 Yıl")?
 
Last edited:
Try this script. It should fetch you the data populated upon pressing the "Galopları" tab:

Code:
Sub GetData()
    Dim elem As Object, trow As Object
    Dim R&, C&, S$

    With New XMLHTTP60
        .Open "POST", "https://yenibeygir.com/at/getatdetaytab", False
        .setRequestHeader "content-type", "application/x-www-form-urlencoded; charset=UTF-8"
        .send "tab=galopTab&id=15673"
        S = .responseText
    End With

    With New HTMLDocument
        .body.innerHTML = S

        For Each elem In .getElementsByClassName("at_Galoplar")(0).Rows
            For Each trow In elem.Cells
                C = C + 1: Cells(R + 1, C) = trow.innerText
            Next trow
            C = 0: R = R + 1
        Next elem
    End With
End Sub

Make sure to add the following libraries before execution:

Code:
Microsoft Html Object Library
Microsoft xml, v6.0

Dear shahin

I'm grateful you're interested in the problem and typing code. But I'm going to have the last two requests about this message. I would be glad if you help.
"https://yenibeygir.com/at/13958/adaletkaya" got "Galopları" on this link. Thank you. How do I get the "Yarışları" data in the same link?
How can I get "Son 1 Yıl" data in this link "https://yenibeygir.com/jokey/10249/ferit-yardimci"?
I've been trying for a long time because of my VBA knowledge, but I couldn't figure it out. I'd really appreciate it if you could help me with those codes. Thanks in advance.
 
The macro crashes (not responding) when I run the code with the for next loop (for example, for i = 15000 to 20000). What would be the reason?
 
Back
Top