Guest User

Untitled

a guest
Jun 14th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. import requests
  2. from pprint import pprint
  3.  
  4. req2 = requests.get('https://statsapi.web.nhl.com/api/v1/game/2017010001/feed/live')
  5. game_data = req2.json()['gameData']
  6. player_data = game_data['players']
  7.  
  8. print(type(player_data))
  9. pprint(player_data)
  10.  
  11. <class 'dict'>
  12. {'ID8467875': {'active': True,
  13. 'alternateCaptain': True,
  14. 'birthCity': 'Ornskoldsvik',
  15. 'birthCountry': 'SWE',
  16. 'birthDate': '1980-09-26',
  17. 'captain': False,
  18. 'currentAge': 37,
  19. 'currentTeam': {'id': 23,
  20. 'link': '/api/v1/teams/23',
  21. 'name': 'Vancouver Canucks',
  22. 'triCode': 'VAN'},
  23. 'firstName': 'Daniel',
  24. 'fullName': 'Daniel Sedin',
  25. 'height': '6' 1"',
  26. 'id': 8467875,
  27. 'lastName': 'Sedin',
  28. 'link': '/api/v1/people/8467875',
  29. 'nationality': 'SWE',
  30. 'primaryNumber': '22',
  31. 'primaryPosition': {'abbreviation': 'LW',
  32. 'code': 'L',
  33. 'name': 'Left Wing',
  34. 'type': 'Forward'},
  35. 'rookie': False,
  36. 'rosterStatus': 'Y',
  37. 'shootsCatches': 'L',
  38. 'weight': 190},
  39. 'ID8467876': {'active': True,
  40. 'alternateCaptain': False,
  41. 'birthCity': 'Ornskoldsvik',
  42. 'birthCountry': 'SWE',
  43. 'birthDate': '1980-09-26',
  44. 'captain': True,
  45. 'currentAge': 37,
  46. 'currentTeam': {'id': 23,
  47. 'link': '/api/v1/teams/23',
  48. 'name': 'Vancouver Canucks',
  49. 'triCode': 'VAN'},
  50. 'firstName': 'Henrik',
  51. 'fullName': 'Henrik Sedin',
  52. 'height': '6' 2"',
  53. 'id': 8467876,
  54. 'lastName': 'Sedin',
  55. 'link': '/api/v1/people/8467876',
  56. 'nationality': 'SWE',
  57. 'primaryNumber': '33',
  58. 'primaryPosition': {'abbreviation': 'C',
  59. 'code': 'C',
  60. 'name': 'Center',
  61. 'type': 'Forward'},
  62. 'rookie': False,
  63. 'rosterStatus': 'Y',
  64. 'shootsCatches': 'L',
  65. 'weight': 183},
  66.  
  67. import requests
  68. from pprint import pprint
  69.  
  70. req2 = requests.get('https://statsapi.web.nhl.com/api/v1/game/2017010001/feed/live')
  71. game_data = req2.json()['gameData']
  72. player_data = game_data['players']
  73.  
  74. for p_data in player_data:
  75.  
  76. print(type(p_data))
  77. pprint(p_data)
  78.  
  79. <class 'str'>
  80. 'ID8470626'
  81. <class 'str'>
  82. 'ID8469639'
  83. <class 'str'>
  84. 'ID8477937'
  85. <class 'str'>
  86. 'ID8470105'
  87. <class 'str'>
  88. 'ID8473614'
  89. <class 'str'>
  90. 'ID8477018'
Add Comment
Please, Sign In to add comment