From e916f8628bb9b4104d8292d3809aaf546b90f509 Mon Sep 17 00:00:00 2001 From: Blallo Date: Wed, 7 Sep 2022 22:17:22 +0200 Subject: [PATCH] Fix: correctly parse flight code --- latecomers/parse.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/latecomers/parse.py b/latecomers/parse.py index 514fef2..fcf1821 100644 --- a/latecomers/parse.py +++ b/latecomers/parse.py @@ -97,9 +97,11 @@ class Details(object): This function fills the fileds related to the flight code, if present and the input matches some heuristics. """ - code = h5.text.strip("\t\n ") - if len(code) > 0 and "flight-numb" in h5.attrib.get("class", ""): - self.code = code + if "flight-numb" not in h5.attrib.get("class", ""): + return + child = h5.xpath(".//strong") + if len(child) == 1: + self.code = child[0].text.strip("\t\n ") def maybe_parse_airport(self, h5: et._ElementTree) -> None: """