Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hockey Data Project
#7
Joeylax54 Wrote:I'm just getting started with Python so bear with me lol, there are currently 32 different roster endpoints (one for each team).
Here some hints on a start and use Requests.
So can collect all data bye iterate over all urls.
Then it look like this,try figure name_search function so can search for Ryan Miller and return back 8468011.
import requests

def nhl_all():
    nhl_lst = []
    for team in range(1,31):
        url = f'https://statsapi.web.nhl.com/api/v1/teams/{team}/roster'
        response = requests.get(url)
        json_data = response.json()
        nhl_lst.append(json_data)
    return nhl_lst

def name_search(json_data, name):
    pass

if __name__ == '__main__':
    json_data = nhl_all()
    print(json_data)
    #name = 'Ryan Miller'
    #print(name_search(json_data, name)) # 8468011

    ''' Test data
    name = 'Ryan Miller'
    # https://statsapi.web.nhl.com/api/v1/teams/24/roster
    # 8468011
    '''
Reply


Messages In This Thread
Hockey Data Project - by Joeylax54 - Mar-24-2020, 05:13 PM
RE: Hockey Data Project - by ndc85430 - Mar-24-2020, 07:17 PM
RE: Hockey Data Project - by Joeylax54 - Mar-24-2020, 08:07 PM
RE: Hockey Data Project - by ndc85430 - Mar-25-2020, 03:30 AM
RE: Hockey Data Project - by Joeylax54 - Mar-26-2020, 08:25 PM
RE: Hockey Data Project - by ndc85430 - Mar-28-2020, 05:16 PM
RE: Hockey Data Project - by snippsat - Mar-28-2020, 10:25 PM
RE: Hockey Data Project - by Joeylax54 - Mar-29-2020, 05:20 AM
RE: Hockey Data Project - by yummykudos - Apr-18-2020, 02:20 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020