nesticot commited on
Commit
f69ccd8
·
verified ·
1 Parent(s): 14c0d21

Update api_scraper.py

Browse files
Files changed (1) hide show
  1. api_scraper.py +13 -1
api_scraper.py CHANGED
@@ -872,8 +872,20 @@ class MLB_Scrape:
872
  """
873
 
874
  game_type_str = ','.join([str(x) for x in game_type])
875
- player_data = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{sport_id}/players?season={season}&gameType=[{game_type_str}]').json()
876
 
 
 
 
 
 
 
 
 
 
 
 
 
 
877
  #Select relevant data that will help distinguish players from one another
878
 
879
  fullName_list = [x['fullName'] if 'fullName' in x else None for x in player_data['people']]
 
872
  """
873
 
874
  game_type_str = ','.join([str(x) for x in game_type])
 
875
 
876
+ if game_type_str = 'S':
877
+ player_data_1 = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{1}/players?season={season}&gameType=[{game_type_str}]').json()
878
+ player_data_2 = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{11}/players?season={season}&gameType=[{game_type_str}]').json()
879
+ player_data_3 = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{12}/players?season={season}&gameType=[{game_type_str}]').json()
880
+ player_data_4 = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{13}/players?season={season}&gameType=[{game_type_str}]').json()
881
+ player_data_5 = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{14}/players?season={season}&gameType=[{game_type_str}]').json()
882
+ player_data = {**player_data_1, **player_data_2, **player_data_3, **player_data_4, **player_data_5}
883
+
884
+
885
+ else:
886
+ player_data = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{sport_id}/players?season={season}&gameType=[{game_type_str}]').json()
887
+
888
+
889
  #Select relevant data that will help distinguish players from one another
890
 
891
  fullName_list = [x['fullName'] if 'fullName' in x else None for x in player_data['people']]