Example #1
0
def get_consolation_winner(league, week):
    html = get_league_html(league, week, constants.consolation_label)
    soup = BeautifulSoup(html, 'html.parser')
    bracket_table = soup.find('table', class_='playoff-bracket')
    winner = bracket_table.find_all('tr')[8]
    a = winner.find('a')
    team_id = extract_team_id(a)
    return league.teams[team_id]
Example #2
0
def parse_league_html(league, week):
    league.teams = parse_standings(get_league_html(league, week, constants.standings_label))
    # if constants.current_week > 1:
    league = add_prev_week_rankings(league, week)

    if constants.current_week > 1:
        league.results = parse_schedule(get_league_html(league, week, constants.prev_week_label))
        for game in league.results:
            game.highest_rank = min(league.teams[game.team1_result.team_id].prev_rank,
                                    league.teams[game.team2_result.team_id].prev_rank)
        league.results.sort(key=lambda g: g.highest_rank)

        league.scores = parse_scores(get_league_html(league, week, constants.prev_week_label))

    if constants.current_week < 17:
        league.schedule = parse_schedule(get_league_html(league, week, constants.cur_week_label))
        for game in league.schedule:
            game.highest_rank = min(league.teams[game.team1_result.team_id].rank,
                                    league.teams[game.team2_result.team_id].rank)
        league.schedule.sort(key=lambda g: g.highest_rank)

    return league