def get_away_team_from_box(self, box): if self.league == "wnba": navigation = [ {"attrs": {"class": "team visitor"}}, {"attrs": {"class": "team-capsule"}}, {"attrs": {"class": "team-name"}}, ] team = scraper.navigate(box, navigation) return team.find_all("span")[1].string elif self.league == "nba": navigation = [ {"attrs": {"class": "team away"}}, {"attrs": {"class": "team-capsule"}}, {"attrs": {"class": "team-name"}}, {"attrs": {"id": re.compile("TeamName")}}, ] teamLink = scraper.navigate(box, navigation) if teamLink.a: return teamLink.a.string else: return teamLink.string else: navigation = [ {"attrs": {"class": "team visitor"}}, {"attrs": {"class": "team-capsule"}}, {"attrs": {"class": "team-name"}}, {"attrs": {"id": re.compile("TeamName")}}, ] teamLink = scraper.navigate(box, navigation) if teamLink.a: return teamLink.a.string else: return teamLink.string
def get_home_score_from_box(self, box): navigation = [ {"attrs": {"class": "team home"}}, {"attrs": {"class": "score"}}, {"attrs": {"class": re.compile("final")}}, ] return scraper.navigate(box, navigation).string
def get_home_record_from_box(self, box): navigation = [ {"attrs": {"class": "team home"}}, {"attrs": {"class": "team-capsule"}}, {"attrs": {"class": "record"}}, ] match = re.compile(r"\((\d+-\d+),.*").search(scraper.navigate(box, navigation).string) if match: return match.group(1) else: return False
def get_away_score_from_box(self, box): if self.league == "nba": navigation = [ {"attrs": {"class": "team away"}}, {"attrs": {"class": "score"}}, {"attrs": {"class": re.compile("final")}}, ] else: navigation = [ {"attrs": {"class": "team visitor"}}, {"attrs": {"class": "score"}}, {"attrs": {"class": re.compile("final")}}, ] return scraper.navigate(box, navigation).string
def get_away_record_from_box(self, box): if self.league == "nba": navigation = [ {"attrs": {"class": "team away"}}, {"attrs": {"class": "team-capsule"}}, {"attrs": {"class": "record"}}, ] else: navigation = [ {"attrs": {"class": "team visitor"}}, {"attrs": {"class": "team-capsule"}}, {"attrs": {"class": "record"}}, ] match = re.compile(r"\((\d+-\d+),.*").search(scraper.navigate(box, navigation).string) if match: return match.group(1) else: return False