nesticot commited on
Commit
8d6881e
·
verified ·
1 Parent(s): c0d2882

Update api_scraper.py

Browse files
Files changed (1) hide show
  1. api_scraper.py +2 -0
api_scraper.py CHANGED
@@ -891,6 +891,7 @@ class MLB_Scrape:
891
  game_type_str = ','.join([str(x) for x in game_type])
892
 
893
  if game_type_str == 'S':
 
894
  player_data = requests.get(f'https://bdfed.stitch.mlbinfra.com/bdfed/stats/player?&env=prod&season={season}&sportId=1&stats=season&group=pitching&gameType=S&limit=1000000&offset=0&sortStat=inningsPitched&order=asc').json()
895
  fullName_list = [x['playerFullName'] if 'playerFullName' in x else None for x in player_data['stats']]
896
  firstName_list = [x['playerFirstName'] if 'playerFirstName' in x else None for x in player_data['stats']]
@@ -907,6 +908,7 @@ class MLB_Scrape:
907
  'team':team_list})
908
 
909
  else:
 
910
  player_data = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{sport_id}/players?season={season}&gameType=[{game_type_str}]').json()['people']
911
 
912
  #Select relevant data that will help distinguish players from one another
 
891
  game_type_str = ','.join([str(x) for x in game_type])
892
 
893
  if game_type_str == 'S':
894
+ print("WE MADE IT TO SPRING")
895
  player_data = requests.get(f'https://bdfed.stitch.mlbinfra.com/bdfed/stats/player?&env=prod&season={season}&sportId=1&stats=season&group=pitching&gameType=S&limit=1000000&offset=0&sortStat=inningsPitched&order=asc').json()
896
  fullName_list = [x['playerFullName'] if 'playerFullName' in x else None for x in player_data['stats']]
897
  firstName_list = [x['playerFirstName'] if 'playerFirstName' in x else None for x in player_data['stats']]
 
908
  'team':team_list})
909
 
910
  else:
911
+ print("WE DID NOT MAKE IT TO SPRING")
912
  player_data = requests.get(url=f'https://statsapi.mlb.com/api/v1/sports/{sport_id}/players?season={season}&gameType=[{game_type_str}]').json()['people']
913
 
914
  #Select relevant data that will help distinguish players from one another