Пример #1
0
 def test_match_statistic_parser_rushing_stat(self):
     """
     Test is parser return rushing stat data
     """
     __rushing = {
         'home_team': [
             {
                 'player_id': 2284778,
                 'player_name': 'Mateusz Rycombel',
                 'att': 20,
                 'yds': 246,
                 'yds_a': 12.3,
                 'lng': 38,
             },
             {
                 'player_id': 2327906,
                 'player_name': 'Szymon Gatner',
                 'att': 5,
                 'yds': 25,
                 'yds_a': 5,
                 'lng': 9,
             },
             {
                 'player_id': 2246980,
                 'player_name': 'Wiktor Witaszek',
                 'att': 8,
                 'yds': 52,
                 'yds_a': 6.5,
                 'lng': 13,
             },
         ],
         'away_team': [
             {
                 'player_id': 2231925,
                 'player_name': 'Radosław Hajok',
                 'att': 32,
                 'yds': -14,
                 'yds_a': -0.4,
                 'lng': 8,
             },
             {
                 'player_id': 2231921,
                 'player_name': 'Anatol Stiller',
                 'att': 5,
                 'yds': 52,
                 'yds_a': 10.4,
                 'lng': 25,
             },
         ]
     }
     f = open('test_match_statistic.txt', encoding="utf8")
     f_data = f.read()
     f.close()
     match_parser = MatchStatisticParser(2029125, f_data)
     rushing_stat = match_parser.get_teams_rushing()
     self.assertDictEqual(rushing_stat, __rushing)
Пример #2
0
def get_matches_statistic(match_ids: Tuple[int], verbose: bool = False):
    matches = []
    for match_id in match_ids:
        page_boxscore = get_match_boxscore_page(match_id, verbose)
        msp = MatchStatisticParser(match_id, page_boxscore)
        msp.get_teams()
        msp.get_score()
        msp.get_scoring()
        msp.get_teams_stat()
        msp.get_teams_passing()
        msp.get_teams_rushing()
        msp.get_teams_receiving()
        msp.get_teams_kicking()
        msp.get_teams_defense()
        result = msp.get_result()
        page = get_match_page(match_id, verbose)
        mp = MatchParser(page)
        result['audience'] = mp.get_audience()
        result['home_team']['downs'] = mp.get_team_evens(result['home_team']['name'])
        result['away_team']['downs'] = mp.get_team_evens(result['away_team']['name'])
        matches.append(result)
        time.sleep(3)
    return matches