From 62301faf936f8b0d1696bb1d41a6e0f05df6acb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B9=20=D0=A7=D0=B5=D1=80=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BA=D0=BE?= Date: Fri, 24 Apr 2026 17:23:48 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=817?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scheduler.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scheduler.py b/scheduler.py index 07df1b3..ada8dd0 100644 --- a/scheduler.py +++ b/scheduler.py @@ -194,6 +194,13 @@ def fetch_html(url: str) -> str: 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: """ Получение 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") if live: 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 - score2 = (scores[2].text).replace("-", 0) if len(scores) > 1 else None + score1 = parse_score(scores[0].text) if len(scores) > 0 else None + score2 = parse_score(scores[2].text) if len(scores) > 2 else None return [{"status": "live", "home_score": score1, "away_score": score2}] raise NotImplementedError("Implement fetch_match_live_data(match_id) by yourself")