Looking for some help with HTML/Excel Web Scraping

corollary

New Member
Joined
May 31, 2014
Messages
18
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.

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.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top