Mar-29-2020, 05:20 AM
I found the simple solution to find players from different teams
NHL_url = 'http://statsapi.web.nhl.com' url_extension = '?hydrate=stats(splits=statsSingleSeason)' url_teams = 'https://statsapi.web.nhl.com/api/v1/teams' url_teams2 = 'https://statsapi.web.nhl.com/api/v1/teams/' url_roster_extension = '/roster' with urlopen(url_teams) as response: source = response.read() data = json.loads(source) for teams in data['teams']: team_id2 = teams['id'] url_full2 = url_teams2 + str(team_id2) + url_roster_extension url_roster = url_full2 with urlopen(url_roster) as response: source = response.read() data = json.loads(source) for item in data['roster']: if item['person']['fullName'] == Player_Name: if item['position']['code'] == 'G': goalie_code = (item['person']['link']) url_full = NHL_url + str(goalie_code) + url_extension with urlopen(url_full) as response: source = response.read() data = json.loads(source) for item5 in data['people']: print('') print(item5['fullName']) for item2 in item5['stats']: for item3 in item2['splits']: wins = item3['stat']['wins'] losses = item3['stat']['losses'] goalsAgainst = item3['stat']['goalsAgainst'] shotsAgainst = item3['stat']['shotsAgainst'] evenSaves = item3['stat']['evenSaves'] savePercentage = item3['stat']['savePercentage'] goalagainstaverage = item3['stat']['goalAgainstAverage'] print('') print('Wins: ', wins) print('Losses: ', losses) print('GA: ', goalsAgainst) print('SA: ', shotsAgainst) print('SV: ', evenSaves) print('SV%: ', savePercentage, '%') print('GAA: ', goalagainstaverage, )