Skip to content

Commit 1327957

Browse files
committed
Fix Joined On info in Clubs/Players endpoint (#68)
1 parent 3555d4f commit 1327957

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

app/services/clubs/players.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def __parse_club_players(self) -> list[dict]:
5151
page_players_signed_from = self.page.xpath(
5252
Clubs.Players.Past.PAGE_SIGNED_FROM if self.past else Clubs.Players.Present.PAGE_SIGNED_FROM,
5353
)
54+
page_players_joined_on = self.page.xpath(
55+
Clubs.Players.Past.PAGE_SIGNED_FROM if self.past else Clubs.Players.Present.PAGE_SIGNED_FROM,
56+
)
5457
players_ids = [extract_from_url(url) for url in self.get_list_by_xpath(Clubs.Players.URLS)]
5558
players_names = self.get_list_by_xpath(Clubs.Players.NAMES)
5659
players_positions = self.get_list_by_xpath(Clubs.Players.POSITIONS)
@@ -71,9 +74,7 @@ def __parse_club_players(self) -> list[dict]:
7174
Clubs.Players.Past.FOOTS if self.past else Clubs.Players.Present.FOOTS,
7275
remove_empty=False,
7376
)
74-
players_joined_on = self.get_list_by_xpath(
75-
Clubs.Players.Past.JOINED_ON if self.past else Clubs.Players.Present.JOINED_ON,
76-
)
77+
players_joined_on = ["; ".join(e.xpath(Clubs.Players.JOINED_ON)) for e in page_players_joined_on]
7778
players_joined = ["; ".join(e.xpath(Clubs.Players.JOINED)) for e in page_players_infos]
7879
players_signed_from = ["; ".join(e.xpath(Clubs.Players.SIGNED_FROM)) for e in page_players_signed_from]
7980
players_contracts = (

app/utils/xpath.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,21 @@ class Players:
149149
SIGNED_FROM = ".//a//img//@title"
150150
MARKET_VALUES = "//td[@class='rechts hauptlink']//text()"
151151
STATUSES = ".//td[@class='hauptlink']//span//@title"
152+
JOINED_ON = ".//text()"
152153

153154
class Present:
154155
PAGE_SIGNED_FROM = "//div[@id='yw1']//td[8]"
156+
PAGE_JOINED_ON = "//div[@id='yw1']//td[7]"
155157
HEIGHTS = "//div[@id='yw1']//td[5]//text()"
156158
FOOTS = "//div[@id='yw1']//td[6]//text()"
157-
JOINED_ON = "//div[@id='yw1']//td[7]//text()"
158159
CONTRACTS = "//div[@id='yw1']//td[9]//text()"
159160

160161
class Past:
161162
PAGE_SIGNED_FROM = "//div[@id='yw1']//td[9]"
163+
PAGE_JOINED_ON = "//div[@id='yw1']//td[8]"
162164
CURRENT_CLUB = "//div[@id='yw1']//td[5]//img//@title"
163165
HEIGHTS = "//div[@id='yw1']//td[6]/text()"
164166
FOOTS = "//div[@id='yw1']//td[7]//text()"
165-
JOINED_ON = "//div[@id='yw1']//td[8]//text()"
166167
CONTRACTS = "//div[@id='yw1']//td[10]//text()"
167168

168169

0 commit comments

Comments
 (0)