From 9bbafe7c35793ee18802b012d474d13222e84c2b 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: Mon, 25 May 2026 11:28:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B8=20=D1=81=D0=B0=D0=B9=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parsers/parser_game.py | 16 ++++++++++++---- parsers/parser_players.py | 16 ++++++++++++---- parsers/parser_schedule.py | 16 ++++++++++++---- parsers/parser_standings.py | 16 ++++++++++++---- parsers/parser_teams.py | 16 ++++++++++++---- 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/parsers/parser_game.py b/parsers/parser_game.py index 57bfe15..879ded9 100644 --- a/parsers/parser_game.py +++ b/parsers/parser_game.py @@ -7,10 +7,18 @@ BASE_MATCH_URL = "https://wfl.rfs.ru/match/" def fetch_html(url: str) -> str: - headers = {"User-Agent": "Mozilla/5.0", "Accept": "*/*"} - r = requests.get(url, headers=headers, timeout=20) - r.raise_for_status() - return r.text + headers = { + "User-Agent": "Mozilla/5.0", + "Accept": "*/*" + } + + try: + r = requests.get(url, headers=headers, timeout=20) + r.raise_for_status() + return r.text + + except requests.exceptions.RequestException as e: + return f"Сайт недоступен: {e}" def extract_player_id_from_href(href: str) -> str: diff --git a/parsers/parser_players.py b/parsers/parser_players.py index c860913..8e19245 100644 --- a/parsers/parser_players.py +++ b/parsers/parser_players.py @@ -17,10 +17,18 @@ AMPLUA_FULL = { def fetch_html(url: str) -> str: - headers = {"User-Agent": "Mozilla/5.0", "Accept": "*/*"} - r = requests.get(url, headers=headers, timeout=20) - r.raise_for_status() - return r.text + headers = { + "User-Agent": "Mozilla/5.0", + "Accept": "*/*" + } + + try: + r = requests.get(url, headers=headers, timeout=20) + r.raise_for_status() + return r.text + + except requests.exceptions.RequestException as e: + return f"Сайт недоступен: {e}" def get_links(html: str) -> list[dict]: diff --git a/parsers/parser_schedule.py b/parsers/parser_schedule.py index 3a9e7a7..b4de10e 100644 --- a/parsers/parser_schedule.py +++ b/parsers/parser_schedule.py @@ -51,10 +51,18 @@ def parse_russian_date(date_str: str, year: int | None = None) -> datetime: def fetch_html(url: str) -> str: - headers = {"User-Agent": "Mozilla/5.0", "Accept": "*/*"} - response = requests.get(url, headers=headers, timeout=20) - response.raise_for_status() - return response.text + headers = { + "User-Agent": "Mozilla/5.0", + "Accept": "*/*" + } + + try: + r = requests.get(url, headers=headers, timeout=20) + r.raise_for_status() + return r.text + + except requests.exceptions.RequestException as e: + return f"Сайт недоступен: {e}" def normalize_status(score1: str | None, score2: str | None, dt: datetime) -> str: diff --git a/parsers/parser_standings.py b/parsers/parser_standings.py index 41ac1ea..820f156 100644 --- a/parsers/parser_standings.py +++ b/parsers/parser_standings.py @@ -8,10 +8,18 @@ SEASON = "2025/2026" def fetch_html(url: str) -> str: - headers = {"User-Agent": "Mozilla/5.0", "Accept": "*/*"} - r = requests.get(url, headers=headers, timeout=20) - r.raise_for_status() - return r.text + headers = { + "User-Agent": "Mozilla/5.0", + "Accept": "*/*" + } + + try: + r = requests.get(url, headers=headers, timeout=20) + r.raise_for_status() + return r.text + + except requests.exceptions.RequestException as e: + return f"Сайт недоступен: {e}" def parse_standings(html: str) -> list[dict]: diff --git a/parsers/parser_teams.py b/parsers/parser_teams.py index 1abae50..552bd4c 100644 --- a/parsers/parser_teams.py +++ b/parsers/parser_teams.py @@ -9,10 +9,18 @@ TEAMS_URL = "https://wfl.rfs.ru/tournament/1061879/teams" def fetch_html(url: str) -> str: - headers = {"User-Agent": "Mozilla/5.0", "Accept": "*/*"} - response = requests.get(url, timeout=30, headers=headers) - response.raise_for_status() - return response.text + headers = { + "User-Agent": "Mozilla/5.0", + "Accept": "*/*" + } + + try: + r = requests.get(url, headers=headers, timeout=20) + r.raise_for_status() + return r.text + + except requests.exceptions.RequestException as e: + return f"Сайт недоступен: {e}" def get_links(html) -> list: