Sub Galoplar()
Sheets("Galop").Select
Range("A1").Select
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
I get "Galopları" from the "Web address" link with the above code. But I can't get "Yarışları" data with the following code.
Sub Yarislar()
Sheets("Yaris").Select
Range("A1").Select
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=yarisTab&id=15673"
S = .responseText
End With
With New HTMLDocument
.body.innerHTML = S
For Each elem In .getElementsByClassName("at_Yarislar")(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
My question is about, where am I making a mistake?
How do I use a vba code to get the "Son 1 Yıl" data on the "Web address" link?
The initial landing tab does not have jquery initiated XHR events which the other tabs do.
You can issue a GET request against your landing page to grab the table by its class name for the first tab.
For your second question (as you are unable to post it):
Edit: There now seems to be problems with late bound clipboard reference in some cases. Here is generic early bound method where hTable is the target HTMLTable object.
For clipboard early bound go VBE > Tools > References > Microsoft-Forms 2.0 Object Library.
If you add a UserForm to your project, the library will get automatically added.