shahin
Active Member
Hi there! I tried to parse a table but unfortunately couldn't. So far when i scraped any table i used three tag names usually: "table", "tr" and "td". But in this case i found another tag name "th" which is making me confused. I'm pasting here the code i have written. Any help would be greatly appreciated.
Code:
Sub TableData()
Dim http As New MSXML2.XMLHTTP60, html As New HTMLDocument
Dim topics As Object, topic As Object, posts As Object, post As Object
Dim x As Long, y As Long
x = 2
y = 1
With http
.Open "GET", "http://www.espncricinfo.com/rankings/content/page/211270.html", False
.send
html.body.innerHTML = .responseText
End With
Set topics = html.getElementsByTagName("table")
For Each topic In topics
For Each posts In topic.getElementsByTagName("tr")
For Each post In posts.getElementsByTagName("th")
Cells(x, y) = post.innerText
y = y + 1
Next post
y = 1
x = x + 1
Next posts
Next topic
End Sub