Add get_teams
This commit is contained in:
@@ -252,3 +252,30 @@ class GameChangerClient():
|
||||
lineup.insert(dh_index+1, d)
|
||||
|
||||
return lineup
|
||||
|
||||
def get_teams(self):
|
||||
url = "https://gc.com/account/teams"
|
||||
|
||||
page = self.session.get(url=url)
|
||||
soup = BeautifulSoup(page.content, "html.parser")
|
||||
team_elements = [i for i in soup.find_all("li") if i.attrs.get("data-team-id")]
|
||||
teams = []
|
||||
for i, team_element in enumerate(team_elements):
|
||||
league_type, number_of_games = [
|
||||
c.text.strip() for c in team_element.findChildren("li")
|
||||
][1:3]
|
||||
season_slug, team_slug = (
|
||||
team_element.find("a").attrs.get("href", "///").split("/")[2:]
|
||||
)
|
||||
teams.append(
|
||||
{
|
||||
"name": team_element.find("a").text,
|
||||
"id": team_element.attrs.get("data-team-id"),
|
||||
"season": team_element.findPrevious("header").text,
|
||||
"league_type": league_type,
|
||||
"number_of_games": number_of_games,
|
||||
"season_slug": season_slug,
|
||||
"team_slug": team_slug,
|
||||
}
|
||||
)
|
||||
return teams
|
||||
|
||||
Reference in New Issue
Block a user