def get_season(): url = f'{API_URL}/match_collections?statuses[]=waiting&' + \ f'tab=admin_created&type=fantasy&per_page=10&page=0' # seasons_data = ftStats.get_page_data(ftStats.get_html(url)) authorization = {'Authorization': 'Bearer fanteam undefined'} platform = Parser(url, authorization) seasons_data = platform.parserResult() # print(seasons_data) seasons = {} for item in seasons_data['seasons']: year = item.get('season') league = item.get('league')['name'] gameType = item.get('league')['gameType'] season_id = item.get('id') finalRound = item.get('finalRound') lastRound = item.get('lastRound') seasons.update({ season_id: { 'year': year, 'league': league, 'gameType': gameType, 'finalRound': finalRound, 'lastRound': lastRound } }) return seasons
def main(kindOfSport='football', season_id=387, gameweek=6, skipNonPlaying=True, numTourn=176601, enableNumTourn=False): """Request information about the players. General request""" url = f'{API_URL}/seasons/{season_id}/players?season_id={season_id}&' + \ f'white_label=fanteam&round={gameweek}' # get_realPlayers(get_page_data(get_html(url)), kindOfSport, gameweek) authorization = {'Authorization': 'Bearer fanteam undefined'} platform = Parser(url, authorization) get_realPlayers(platform.parserResult(), kindOfSport, season_id, gameweek, skipNonPlaying, numTourn, enableNumTourn)
def get_ownership(realPlayerId, numTourn, gameweek, season_id): url = f'{API_URL}/real_players/{realPlayerId}?season_id={season_id}&' + \ f'round={gameweek}&tournament_id={numTourn}' authorization = {'Authorization': 'Bearer fanteam undefined'} plarform_player = Parser(url, authorization) data_player = plarform_player.parserResult() try: selectedRatio = data_player['tournamentPlayerStats'].get( 'selectedRatio') captainedRatio = data_player['tournamentPlayerStats'].get( 'captainedRatio') except AttributeError: selectedRatio, captainedRatio = ['', ''] return selectedRatio, captainedRatio
def main(): urls = TOURNAMENTS_URL.split(', ') for url in urls: tournament = Parser(url) get_pageData(tournament.parserResult())