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: