def test_parse_october_2001_schedule_for_month_url_paths_(self): urls = schedule.parse_schedule_for_month_url_paths( self.october_2001_html) expected_urls = [ "https://www.basketball-reference.com/leagues/NBA_2001_games-november.html", "https://www.basketball-reference.com/leagues/NBA_2001_games-december.html", "https://www.basketball-reference.com/leagues/NBA_2001_games-january.html", "https://www.basketball-reference.com/leagues/NBA_2001_games-february.html", "https://www.basketball-reference.com/leagues/NBA_2001_games-march.html", "https://www.basketball-reference.com/leagues/NBA_2001_games-april.html", "https://www.basketball-reference.com/leagues/NBA_2001_games-may.html", "https://www.basketball-reference.com/leagues/NBA_2001_games-june.html", ] self.assertIsNotNone(urls) self.assertEqual(urls, expected_urls)
def season_schedule(season_end_year): url = '{BASE_URL}/leagues/NBA_{season_end_year}_games.html'.format( BASE_URL=BASE_URL, season_end_year=season_end_year) response = requests.get(url=url) response.raise_for_status() season_schedule_values = parse_schedule(response.content) other_month_url_paths = parse_schedule_for_month_url_paths( response.content) for month_url_path in other_month_url_paths: url = '{BASE_URL}{month_url_path}'.format( BASE_URL=BASE_URL, month_url_path=month_url_path) monthly_schedule = schedule_for_month(url=url) season_schedule_values.extend(monthly_schedule) return season_schedule_values