So the following code hopes to return the entirety of the play-by-play table at a link like this: Providence vs. Villanova - Play-By-Play - January 24, 2016 - ESPN.
It's a piece of code I found leafing through the internet and am trying to adapt for my purposes. I've leaned heavily on web query for my uses to this point, and am trying to branch out.
It works - but only sort of. Running the above code gets a piece of the table, but not in order, or the whole thing. I believe I've ruled out a problem wherein it was copying over pieces of itself as it moves through, but haven't found a solution for the 'not picking up everything part.'
I'm hoping for a little bit of help in trying to figure this one out. If you're more inclined to say 'pshhh, you're asking me to do your work for you,' you're not wrong - I haven't taken a long enough look at this to say I've exhausted all possibilities. If that's the case, and you're aware of a good reference to start teaching myself how to better do this stuff, please feel free to reply with that!
If you're feeling very generous though, I would love specific code help/pointers toward what I'm missing.
In any case, really appreciate any help or references you can give me.
Code:
Sub test()
Set IE = CreateObject("InternetExplorer.Application")
my_url = "http://www.espn.com/mens-college-basketball/playbyplay?gameId=400861696"
With IE
.Visible = True
.navigate my_url
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not IE.Busy And IE.readyState = 4
DoEvents
Loop
End With
Set tbl = IE.document.getElementsByTagName("tbody")
For Each itm In tbl
i = 1
For Each itm2 In itm.Rows
For Each cell In itm2.Cells
ActiveSheet.Cells(i, 2) = cell.innertext
i = i + 1
Next
Next
Next
End Sub
It's a piece of code I found leafing through the internet and am trying to adapt for my purposes. I've leaned heavily on web query for my uses to this point, and am trying to branch out.
It works - but only sort of. Running the above code gets a piece of the table, but not in order, or the whole thing. I believe I've ruled out a problem wherein it was copying over pieces of itself as it moves through, but haven't found a solution for the 'not picking up everything part.'
I'm hoping for a little bit of help in trying to figure this one out. If you're more inclined to say 'pshhh, you're asking me to do your work for you,' you're not wrong - I haven't taken a long enough look at this to say I've exhausted all possibilities. If that's the case, and you're aware of a good reference to start teaching myself how to better do this stuff, please feel free to reply with that!
If you're feeling very generous though, I would love specific code help/pointers toward what I'm missing.
In any case, really appreciate any help or references you can give me.