Need help pulling NBA Stats (similar to Stock Quotes)

UCSDKID

New Member
Joined
Apr 12, 2005
Messages
45
I am trying to build a workbook to track the statistics of the starters for each NBA team. I have the following code to open each player's webpage but when I look at the ResponseText, I don't see the stats anywhere. Can someone give me some guidance.

here is one of the websites. I want to pull the line which shows the statistics for the current season.

http://sports.espn.go.com/nba/players/profile?statsId=3266

Here is the code i have so far:

Code:
Sub GetStats()

Dim xmlhttp, cl As Range, rng As Range
Dim strURL As String, RtnPage As String

'Create the XML document type
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")

'Get my range of the stock quotes
Set rng = Range("C2:C3")

For Each cl In rng

    'Check to see if Cell has a link to the players page
    If cl.Hyperlinks.Count > 0 Then
    
        'Open a connection to the server and get the Player's Statistics
        strURL = cl.Hyperlinks.Item(1).Address
        
        'get the strURL
        xmlhttp.Open "GET", strURL, False, "", ""
        
        'send the information
        xmlhttp.Send
        
        RtnPage = xmlhttp.ResponseText
        
        Debug.Print RtnPage
        
    End If

Next cl

End Sub

Thanks for the help.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
The debug window is only good for about 200 lines.

This is very dirty. I just threw it together to give you some ideas. You could load the html doc into a DOM class and get the actual cell values but this does work well enough...

Code:
Sub GetStats()

Dim xmlhttp, cl As Range, rng As Range
Dim strURL As String, RtnPage As String, x
Dim y, z

'Create the XML document type
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")

'Get my range of the stock quotes
Set rng = Range("C2:C3")

For Each cl In rng

    'Check to see if Cell has a link to the players page
    If cl.Hyperlinks.Count > 0 Then
    
        'Open a connection to the server and get the Player's Statistics
        strURL = cl.Hyperlinks.Item(1).Address
        
        'get the strURL
        xmlhttp.Open "GET", strURL, False, "", ""
        
        'send the information
        xmlhttp.Send
        
        RtnPage = xmlhttp.ResponseText
        
        x = InStr(RtnPage, "Season</td>") + 11
        y = InStr(x, RtnPage, "</tr>")
        z = Mid(RtnPage, x, y - x)
        z = Mid(z, 5)
        z = Replace(z, "</td>", "")
        z = Split(z, "<td>")
        
        'debug.print stats
        For y = 0 To UBound(z)
            Debug.Print z(y)
        Next
    End If

Next cl

End Sub

Tom
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,923
Members
448,533
Latest member
thietbibeboiwasaco

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