фикс7
This commit is contained in:
11
scheduler.py
11
scheduler.py
@@ -194,6 +194,13 @@ def fetch_html(url: str) -> str:
|
|||||||
return r.text
|
return r.text
|
||||||
|
|
||||||
|
|
||||||
|
def parse_score(value: str) -> int | None:
|
||||||
|
value = value.strip()
|
||||||
|
if value == "-":
|
||||||
|
return None
|
||||||
|
return int(value)
|
||||||
|
|
||||||
|
|
||||||
def fetch_match_live_data(match_id: int) -> dict:
|
def fetch_match_live_data(match_id: int) -> dict:
|
||||||
"""
|
"""
|
||||||
Получение live-данных матча с сайта.
|
Получение live-данных матча с сайта.
|
||||||
@@ -230,8 +237,8 @@ def fetch_match_live_data(match_id: int) -> dict:
|
|||||||
live = soup.find("section", class_="game game--future game--live js-game-live-label game--shadow game--progress")
|
live = soup.find("section", class_="game game--future game--live js-game-live-label game--shadow game--progress")
|
||||||
if live:
|
if live:
|
||||||
scores = soup.find("div", class_="score__container").find_all("div", class_="score__item")
|
scores = soup.find("div", class_="score__container").find_all("div", class_="score__item")
|
||||||
score1 = (scores[0].text).replace("-", 0) if len(scores) > 0 else None
|
score1 = parse_score(scores[0].text) if len(scores) > 0 else None
|
||||||
score2 = (scores[2].text).replace("-", 0) if len(scores) > 1 else None
|
score2 = parse_score(scores[2].text) if len(scores) > 2 else None
|
||||||
return [{"status": "live", "home_score": score1, "away_score": score2}]
|
return [{"status": "live", "home_score": score1, "away_score": score2}]
|
||||||
|
|
||||||
raise NotImplementedError("Implement fetch_match_live_data(match_id) by yourself")
|
raise NotImplementedError("Implement fetch_match_live_data(match_id) by yourself")
|
||||||
|
|||||||
Reference in New Issue
Block a user