davidjkrause / sportsipy

A free sports API written for python
MIT License
33 stars 8 forks source link

NBA data returning None #9

Open daneasterman opened 3 months ago

daneasterman commented 3 months ago

Hi there using this code with hard-coded ids. I am no longer able to get any player data - it is just returning None with no further explanation:

player_list_2024 = [{'id': 'sheppbe01', 'price': 2}, {'id': 'walkeja02', 'price': 3}, {'id': 'walshjo01', 'price': 1}, {'id': 'holmgch01', 'price': 46}, {'id': 'wallaca01', 'price': 5}, {'id': 'jacksan01', 'price': 2}, {'id': 'livinch01', 'price': 2}, {'id': 'bufkiko01', 'price': 2}, {'id': 'gueyemo02', 'price': 2}, {'id': 'hoodsja01', 'price': 2}, {'id': 'lewisma05', 'price': 1}, {'id': 'livelde01', 'price': 8}, {'id': 'prospol01', 'price': 2}, {'id': 'jackstr02', 'price': 4}, {'id': 'podzibr01', 'price': 11}, {'id': 'santogu01', 'price': 1}, {'id': 'jonesco02', 'price': 2}, {'id': 'georgke01', 'price': 12}, {'id': 'hendrita01', 'price': 3}, {'id': 'sensabr01', 'price': 1}, {'id': 'brownko01', 'price': 1}, {'id': 'hawkijo01', 'price': 6}, {'id': 'liddeej01', 'price': 1}, {'id': 'pickeja02', 'price': 1}, {'id': 'strawju01', 'price': 3}, {'id': 'tysonhu01', 'price': 1}, {'id': 'councri01', 'price': 1}, {'id': 'thompam01', 'price': 15}, {'id': 'whitmca01', 'price': 8}, {'id': 'coulibi01', 'price': 5}, {'id': 'vukcetr01', 'price': 1}, {'id': 'millele01', 'price': 5}, {'id': 'dickgr01', 'price': 6}, {'id': 'freemja01', 'price': 1}, {'id': 'bitimon01', 'price': 1}, {'id': 'phillju01', 'price': 2}, {'id': 'cissosi01', 'price': 1}, {'id': 'wembavi01', 'price': 256}, {'id': 'blackan01', 'price': 4}, {'id': 'howarje01', 'price': 3}, {'id': 'clownno01', 'price': 3}, {'id': 'whiteda01', 'price': 2}, {'id': 'wilsoja03', 'price': 2}, {'id': 'jaqueja01', 'price': 9}, {'id': 'sassema01', 'price': 2}, {'id': 'thompau01', 'price': 6}, {'id': 'millebr02', 'price': 32}, {'id': 'smithni01', 'price': 2}, {'id': 'camarto01', 'price': 3}, {'id': 'hendesc01', 'price': 12}, {'id': 'murrakr01', 'price': 2}, {'id': 'reathdu01', 'price': 2}, {'id': 'ruperra01', 'price': 1}]

for player_dict in player_list_2024:
    time.sleep(0.5)
    player = Player(player_dict["id"])  

    player_record = {
        "Player Name": player.name,
        "Player Efficiency Rating": player.player_efficiency_rating,
        "Win Shares": player.win_shares,
        "Box Plus Minus": player.box_plus_minus,
        "Value Over Replacement Player": player.value_over_replacement_player,
        "True Shooting Percentage": player.true_shooting_percentage,
        "Career Salary": player.salary,
        "Low Ask": player_dict["price"]
    }
    print(player_record)

I'm installing the package with this command: pip install git+https://github.com/davidjkrause/sportsipy@master After install the message is: Successfully installed sportsipy-0.6.0

I'm also using Python 3.9.6

Can you help? Thanks very much in advance!

davidjkrause commented 1 week ago

Was not able to reproduce this using the following code, note I used a longer delay of 20 seconds, I suspect the site will block you fairely quickly if you use a delay of 0.5 seconds. You might even need to use 30 seconds and just be patient gathering the data.

from sportsipy.nba.roster import Player
import time

player_list_2024 = [{'id': 'sheppbe01', 'price': 2}, {'id': 'walkeja02', 'price': 3}]
for player_dict in player_list_2024:
    time.sleep(20)
    player = Player(player_dict["id"])  

    player_record = {
        "Player Name": player.name,
        "Player Efficiency Rating": player.player_efficiency_rating,
        "Win Shares": player.win_shares,
        "Box Plus Minus": player.box_plus_minus,
        "Value Over Replacement Player": player.value_over_replacement_player,
        "True Shooting Percentage": player.true_shooting_percentage,
        "Career Salary": player.salary,
        "Low Ask": player_dict["price"]
    }
    print(player_record)

The output was:

'Player Name': 'Ben Sheppard', 'Player Efficiency Rating': 8.0, 'Win Shares': 1.0, 'Box Plus Minus': -3.4, 'Value Over Replacement Player': -0.4, 'True Shooting Percentage': 0.534, 'Career Salary': 2537160, 'Low Ask': 2}
{'Player Name': 'Jarace Walker', 'Player Efficiency Rating': 10.8, 'Win Shares': 0.4, 'Box Plus Minus': -1.1, 'Value Over Replacement Player': 0.2, 'True Shooting Percentage': 0.522, 'Career Salary': 6059520, 'Low Ask': 3}