Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NCAAF boxscores showing incorrect teams #504

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions sportsreference/ncaaf/boxscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,9 +1438,15 @@ def _get_team_names(self, game):
# Grab the first <td...> tag for each <tr> row in the boxscore,
# representing the name for each participating team.
links = [g('td:first') for g in game('tr').items()]
# The away team is the second link in the boxscore
away = links[1]
# The home team is the last (3rd) link in the boxscore
# The date will be included periodically in the boxscore which adds a
# third table row to the boxscore. In this case, the away team is the
# second link (index 1). Othertimes, the date is not included, and the
# first link is the away team.
if len(links) == 2:
away = links[0]
else:
away = links[1]
# The home team is the last (2nd or 3rd) link in the boxscore
home = links[-1]
non_di = False
scores = re.findall(r'<td class="right">\d+</td>', str(game))
Expand Down
136 changes: 68 additions & 68 deletions tests/integration/boxscore/test_ncaaf_boxscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2751,8 +2751,8 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs):
],
'8-31-2017': [
{'boxscore': '2017-08-31-arizona-state',
'away_name': 'Arizona State',
'away_abbr': 'arizona-state',
'away_name': 'New Mexico State',
'away_abbr': 'new-mexico-state',
'away_score': 31,
'away_rank': None,
'home_name': 'Arizona State',
Expand All @@ -2763,116 +2763,116 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs):
'top_25': False,
'winning_name': 'Arizona State',
'winning_abbr': 'arizona-state',
'losing_name': 'Arizona State',
'losing_abbr': 'arizona-state'},
'losing_name': 'New Mexico State',
'losing_abbr': 'new-mexico-state'},
{'boxscore': '2017-08-31-arkansas',
'away_name': 'Arkansas',
'away_abbr': 'arkansas',
'away_name': 'Florida A&M',
'away_abbr': 'Florida A&M',
'away_score': 7,
'away_rank': None,
'home_name': 'Arkansas',
'home_abbr': 'arkansas',
'home_score': 49,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Arkansas',
'winning_abbr': 'arkansas',
'losing_name': 'Arkansas',
'losing_abbr': 'arkansas'},
'losing_name': 'Florida A&M',
'losing_abbr': 'Florida A&M'},
{'boxscore': '2017-08-31-central-michigan',
'away_name': 'Central Michigan',
'away_abbr': 'central-michigan',
'away_name': 'Rhode Island',
'away_abbr': 'Rhode Island',
'away_score': 27,
'away_rank': None,
'home_name': 'Central Michigan',
'home_abbr': 'central-michigan',
'home_score': 30,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Central Michigan',
'winning_abbr': 'central-michigan',
'losing_name': 'Central Michigan',
'losing_abbr': 'central-michigan'},
'losing_name': 'Rhode Island',
'losing_abbr': 'Rhode Island'},
{'boxscore': '2017-08-31-cincinnati',
'away_name': 'Cincinnati',
'away_abbr': 'cincinnati',
'away_name': 'Austin Peay',
'away_abbr': 'Austin Peay',
'away_score': 14,
'away_rank': None,
'home_name': 'Cincinnati',
'home_abbr': 'cincinnati',
'home_score': 26,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Cincinnati',
'winning_abbr': 'cincinnati',
'losing_name': 'Cincinnati',
'losing_abbr': 'cincinnati'},
'losing_name': 'Austin Peay',
'losing_abbr': 'Austin Peay'},
{'boxscore': '2017-08-31-connecticut',
'away_name': 'Connecticut',
'away_abbr': 'connecticut',
'away_name': 'Holy Cross',
'away_abbr': 'Holy Cross',
'away_score': 20,
'away_rank': None,
'home_name': 'Connecticut',
'home_abbr': 'connecticut',
'home_score': 27,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Connecticut',
'winning_abbr': 'connecticut',
'losing_name': 'Connecticut',
'losing_abbr': 'connecticut'},
'losing_name': 'Holy Cross',
'losing_abbr': 'Holy Cross'},
{'boxscore': '2017-08-31-georgia-state',
'away_name': 'Georgia State',
'away_abbr': 'georgia-state',
'away_name': 'Tennessee State',
'away_abbr': 'Tennessee State',
'away_score': 17,
'away_rank': None,
'home_name': 'Georgia State',
'home_abbr': 'georgia-state',
'home_score': 10,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Georgia State',
'winning_abbr': 'georgia-state',
'winning_name': 'Tennessee State',
'winning_abbr': 'Tennessee State',
'losing_name': 'Georgia State',
'losing_abbr': 'georgia-state'},
{'boxscore': '2017-08-31-idaho',
'away_name': 'Idaho',
'away_abbr': 'idaho',
'away_name': 'Sacramento State',
'away_abbr': 'Sacramento State',
'away_score': 6,
'away_rank': None,
'home_name': 'Idaho',
'home_abbr': 'idaho',
'home_score': 28,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Idaho',
'winning_abbr': 'idaho',
'losing_name': 'Idaho',
'losing_abbr': 'idaho'},
'losing_name': 'Sacramento State',
'losing_abbr': 'Sacramento State'},
{'boxscore': '2017-08-31-indiana',
'away_name': 'Indiana',
'away_abbr': 'indiana',
'away_name': 'Ohio State',
'away_abbr': 'ohio-state',
'away_score': 49,
'away_rank': None,
'away_rank': 2,
'home_name': 'Indiana',
'home_abbr': 'indiana',
'home_score': 21,
'home_rank': None,
'non_di': False,
'top_25': False,
'winning_name': 'Indiana',
'winning_abbr': 'indiana',
'top_25': True,
'winning_name': 'Ohio State',
'winning_abbr': 'ohio-state',
'losing_name': 'Indiana',
'losing_abbr': 'indiana'},
{'boxscore': '2017-08-31-memphis',
'away_name': 'Memphis',
'away_abbr': 'memphis',
'away_name': 'Louisiana-Monroe',
'away_abbr': 'louisiana-monroe',
'away_score': 29,
'away_rank': None,
'home_name': 'Memphis',
Expand All @@ -2883,11 +2883,11 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs):
'top_25': False,
'winning_name': 'Memphis',
'winning_abbr': 'memphis',
'losing_name': 'Memphis',
'losing_abbr': 'memphis'},
'losing_name': 'Louisiana-Monroe',
'losing_abbr': 'louisiana-monroe'},
{'boxscore': '2017-08-31-minnesota',
'away_name': 'Minnesota',
'away_abbr': 'minnesota',
'away_name': 'Buffalo',
'away_abbr': 'buffalo',
'away_score': 7,
'away_rank': None,
'home_name': 'Minnesota',
Expand All @@ -2898,13 +2898,13 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs):
'top_25': False,
'winning_name': 'Minnesota',
'winning_abbr': 'minnesota',
'losing_name': 'Minnesota',
'losing_abbr': 'minnesota'},
'losing_name': 'Buffalo',
'losing_abbr': 'buffalo'},
{'boxscore': '2017-08-31-oklahoma-state',
'away_name': 'Oklahoma State',
'away_abbr': 'oklahoma-state',
'away_name': 'Tulsa',
'away_abbr': 'tulsa',
'away_score': 24,
'away_rank': 10,
'away_rank': None,
'home_name': 'Oklahoma State',
'home_abbr': 'oklahoma-state',
'home_score': 59,
Expand All @@ -2913,53 +2913,53 @@ def test_boxscores_search_multiple_days(self, *args, **kwargs):
'top_25': True,
'winning_name': 'Oklahoma State',
'winning_abbr': 'oklahoma-state',
'losing_name': 'Oklahoma State',
'losing_abbr': 'oklahoma-state'},
'losing_name': 'Tulsa',
'losing_abbr': 'tulsa'},
{'boxscore': '2017-08-31-toledo',
'away_name': 'Toledo',
'away_abbr': 'toledo',
'away_name': 'Elon',
'away_abbr': 'Elon',
'away_score': 13,
'away_rank': None,
'home_name': 'Toledo',
'home_abbr': 'toledo',
'home_score': 47,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Toledo',
'winning_abbr': 'toledo',
'losing_name': 'Toledo',
'losing_abbr': 'toledo'},
'losing_name': 'Elon',
'losing_abbr': 'Elon'},
{'boxscore': '2017-08-31-utah',
'away_name': 'Utah',
'away_abbr': 'utah',
'away_name': 'North Dakota',
'away_abbr': 'North Dakota',
'away_score': 16,
'away_rank': None,
'home_name': 'Utah',
'home_abbr': 'utah',
'home_score': 37,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Utah',
'winning_abbr': 'utah',
'losing_name': 'Utah',
'losing_abbr': 'utah'},
'losing_name': 'North Dakota',
'losing_abbr': 'North Dakota'},
{'boxscore': '2017-08-31-wake-forest',
'away_name': 'Wake Forest',
'away_abbr': 'wake-forest',
'away_name': 'Presbyterian',
'away_abbr': 'Presbyterian',
'away_score': 7,
'away_rank': None,
'home_name': 'Wake Forest',
'home_abbr': 'wake-forest',
'home_score': 51,
'home_rank': None,
'non_di': False,
'non_di': True,
'top_25': False,
'winning_name': 'Wake Forest',
'winning_abbr': 'wake-forest',
'losing_name': 'Wake Forest',
'losing_abbr': 'wake-forest'},
'losing_name': 'Presbyterian',
'losing_abbr': 'Presbyterian'},
{'boxscore': '2017-09-04-georgia-tech',
'away_name': 'Tennessee',
'away_abbr': 'tennessee',
Expand Down