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.
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
L

Legacy 98055

Guest
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,521
Messages
5,572,624
Members
412,475
Latest member
JaredNAU
Top