Novice, Help with Getting Web Page Data

bheron

New Member
Joined
Feb 1, 2008
Messages
4
Hi all,

I'd like to automatically import NCAA basketball scores from the March Madness tourney into my spreadsheet. It seems like there are so many ways to do it but none I've found online work for me. Always get errors.

For example, I'd love to be able to take scores from this page, once they're final, and bring into excel. It can be in any format b/c once I have them in Excel I'm fine and can take it from there.


FYI I'm just a casual programmer/novice so most of the stuff I use I pull from other examples and modify to fit my needs. Wanted to call that out in case it gets to complex :-)

Thanks!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Ok, ok fine. I'll figure it out myself ;-) Kidding. but after a few days and countless hours watching videos, reading anything I can find and what feels like over 100 failed code sets I got something to work! Here's the code for anyone that's interested (again I got 99% of this from people online so not even completely sure what all of it does).

Sub LiveScoresImport()

Dim ie As InternetExplorer
Dim ht As HTMLDocument
Dim iRW As Integer


Sheets("Sheet1").Select
Range("A3").Select
Range("A3:A100").Select
Selection.ClearContents

Set ie = New InternetExplorer
'ie.Visible = True


ie.navigate ("Sports Scores on March 19, 2022")


Do Until ie.readyState = READYSTATE_COMPLETE And ie.Busy = False
DoEvents
Loop


Set ht = ie.document

Set elems = ht.getElementsByClassName("text-fg no-underline")


For Each elem In elems
lr = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row + 1
Set divs = elem.getElementsByTagName("div")

Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = elem.innerText
Next


ie.Quit

Range("A3:A100").Select
Selection.TextToColumns Destination:=Range("A3"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="|", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
1), Array(6, 1), Array(7, 1)), TrailingMinusNumbers:=True
Cells.Select
Cells.EntireColumn.AutoFit


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

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