Closed jaecktec closed 1 year ago
It would be nice to specify a day. So the code could be changed to something like this:
def get_timetable_xml(self, hour: Optional[int] = None, date: Optional[datetime] = datetime.now()) -> str: hour_date: datetime = date if hour: hour_date = datetime.strptime(str(hour), "%H") date: str = datetime.now().strftime("%y%m%d") hour: str = hour_date.strftime("%H") response = requests.get( f"https://apis.deutschebahn.com/db-api-marketplace/apis/timetables/v1" f"/plan/{self.station.EVA_NR}/{date}/{hour}", headers=self.api_authentication.get_headers() ) return response.text def get_timetable(self, hour: Optional[int] = None, date: date: Optional[datetime] = None) -> list[Train]: train_list: list[Train] = [] trains = elementTree.fromstringlist(self.get_timetable_xml(hour, date))
Just noticed, this api has no historic data :(
It would be nice to specify a day. So the code could be changed to something like this: