def player_box_scores(day, month, year, output_type=None, output_file_path=None, output_write_option=None, json_options=None): try: http_service = HTTPService(parser=ParserService()) values = http_service.player_box_scores(day=day, month=month, year=year) except requests.exceptions.HTTPError as http_error: if http_error.response.status_code == requests.codes.not_found: raise InvalidDate(day=day, month=month, year=year) else: raise http_error options = OutputOptions.of( file_options=FileOptions.of(path=output_file_path, mode=output_write_option), output_type=output_type, json_options=json_options, csv_options={"column_names": BOX_SCORE_COLUMN_NAMES}) output_service = OutputService( json_writer=JSONWriter(value_formatter=BasketballReferenceJSONEncoder), csv_writer=CSVWriter(value_formatter=format_value)) return output_service.output(data=values, options=options)
def play_by_play(home_team, day, month, year, output_type=None, output_file_path=None, output_write_option=None, json_options=None): try: values = http_client.play_by_play(home_team=home_team, day=day, month=month, year=year) except requests.exceptions.HTTPError as http_error: if http_error.response.status_code == requests.codes.not_found: raise InvalidDate(day=day, month=month, year=year) else: raise http_error return output( values=values, output_type=output_type, output_file_path=output_file_path, output_write_option=output_write_option, csv_writer=CSVWriter(column_names=PLAY_BY_PLAY_COLUMN_NAMES, row_formatter=RowFormatter( data_field_names=PLAY_BY_PLAY_COLUMN_NAMES)), json_options=json_options, )
def player_box_scores(day, month, year, output_type=None, output_file_path=None, output_write_option=None, json_options=None): try: http_service = HTTPService(parser=ParserService()) values = http_service.player_box_scores(day=day, month=month, year=year) except requests.exceptions.HTTPError as http_error: if http_error.response.status_code == requests.codes.not_found: raise InvalidDate(day=day, month=month, year=year) else: raise http_error return output( values=values, output_type=output_type, output_file_path=output_file_path, output_write_option=output_write_option, csv_writer=CSVWriter(column_names=BOX_SCORE_COLUMN_NAMES, row_formatter=RowFormatter( data_field_names=BOX_SCORE_COLUMN_NAMES)), json_options=json_options, )
def player_box_scores(day, month, year): url = '{BASE_URL}/friv/dailyleaders.cgi?month={month}&day={day}&year={year}'.format( BASE_URL=BASE_URL, day=day, month=month, year=year ) response = requests.get(url=url, allow_redirects=False) response.raise_for_status() if response.status_code == requests.codes.ok: page = DailyLeadersPage(html=html.fromstring(response.content)) box_score_parser = PlayerBoxScoresParser( team_abbreviation_parser=TeamAbbreviationParser( abbreviations_to_teams=TEAM_ABBREVIATIONS_TO_TEAM ), location_abbreviation_parser=LocationAbbreviationParser( abbreviations_to_locations=LOCATION_ABBREVIATIONS_TO_POSITION ), outcome_abbreviation_parser=OutcomeAbbreviationParser( abbreviations_to_outcomes=OUTCOME_ABBREVIATIONS_TO_OUTCOME ), seconds_played_parser=SecondsPlayedParser(), ) return box_score_parser.parse(page.daily_leaders) raise InvalidDate(day=day, month=month, year=year)
def team_box_scores(day, month, year, adv=False, output_type=None, output_file_path=None, output_write_option=None, json_options=None): try: values = http_client.team_box_scores(day=day, month=month, year=year, adv=adv) except requests.exceptions.HTTPError as http_error: if http_error.response.status_code == requests.codes.not_found: raise InvalidDate(day=day, month=month, year=year) else: raise http_error return output( values=values, output_type=output_type, output_file_path=output_file_path, output_write_option=output_write_option, csv_writer=team_box_scores_to_csv, encoder=BasketballReferenceJSONEncoder, json_options=json_options, )
def player_box_scores(day, month, year): url = '{BASE_URL}/friv/dailyleaders.cgi?month={month}&day={day}&year={year}'.format( BASE_URL=BASE_URL, day=day, month=month, year=year) response = requests.get(url=url, allow_redirects=False) if 200 <= response.status_code < 300: return parse_player_box_scores(response.content) raise InvalidDate(day=day, month=month, year=year)
def player_box_scores(self, day, month, year): url = '{BASE_URL}/friv/dailyleaders.cgi?month={month}&day={day}&year={year}'.format( BASE_URL=HTTPService.BASE_URL, day=day, month=month, year=year) response = requests.get(url=url, allow_redirects=False) response.raise_for_status() if response.status_code == requests.codes.ok: page = DailyLeadersPage(html=html.fromstring(response.content)) return self.parser.parse_player_box_scores( box_scores=page.daily_leaders) raise InvalidDate(day=day, month=month, year=year)