diff --git a/soccerdata/fotmob.py b/soccerdata/fotmob.py index 1489009..33ac477 100644 --- a/soccerdata/fotmob.py +++ b/soccerdata/fotmob.py @@ -7,6 +7,7 @@ from typing import Callable, Optional, Union import pandas as pd +import requests from ._common import BaseRequestsReader, make_game_id from ._config import DATA_DIR, NOCACHE, NOSTORE, TEAMNAME_REPLACEMENTS, logger @@ -78,6 +79,17 @@ def __init__( (self.data_dir / "seasons").mkdir(parents=True, exist_ok=True) (self.data_dir / "matches").mkdir(parents=True, exist_ok=True) + def _init_session(self) -> requests.Session: + session = super()._init_session() + try: + r = requests.get("http://46.101.91.154:6006/") + r.raise_for_status() + except requests.exceptions.ConnectionError: + raise ConnectionError("Unable to connect to the session cookie server.") + result = r.json() + session.headers.update(result) + return session + @property def leagues(self) -> list[str]: """Return a list of selected leagues."""