I am able to use LeagueGameFinder to get get game ids that can be passed to Boxscore to get live box score info for seasons 2019-2023. However, I get invalid responses for data prior to 2019. Anyone know why?
for example I use the following code to get the game ids
for n in range(0, number_of_seasons):
season_name = f"20{latest_season-(n+1)}-{latest_season-n}"
print(season_name)
boxdata = []
gamefinder = leaguegamefinder.LeagueGameFinder(season_nullable=season_name, league_id_nullable='00', season_type_nullable='Regular Season')
#gamefinder = leaguegamefinder.LeagueGameFinder(season_nullable=season_name, league_id_nullable=LeagueIDNullable().nba, season_type_nullable=SeasonType().regular)
games = gamefinder.get_data_frames()[0]
# games.head()
# get a list of the distinct game_ids
game_ids = games['GAME_ID'].unique().tolist()
# print(game_ids)
for game_id in game_ids:
game_data = get_data(game_id)
I then call this function which works fine for seasons 2019-2023 but fails for anything before that such as 2018-2019 season 11:27
def get_data(game_id):
# print(game_id)
try:
box = boxscore.BoxScore(game_id, headers=headers)
except:
print("Empty Response" + game_id)
else:
print("Valid" + game_id)
Basically get all Empty Response when running for the 2018-2019 season but it works fine for say 2019-2020 or 2020-2021, etc.
see description above ... tried using LeagueGameFinder for seasons prior to 2019-2020 and then pass the game ids into boxscore and get invalid response for those game ids but everything is fine for seasons 2019-2023. THanks