From 7babde6f739923e0546cf53cf4b2882efbea1ccd Mon Sep 17 00:00:00 2001 From: Scotty Allen Date: Sun, 18 Jan 2026 10:14:07 -0700 Subject: [PATCH] Add flight_number field to Flight schema and extraction - Add flight_number: Optional[str] = None to Flight dataclass - Extract flight number from span.Xsgmwe in parse_response() - Flight numbers appear as "F9 1230" or "UA 820" format Co-Authored-By: Claude Opus 4.5 --- fast_flights/core.py | 5 +++++ fast_flights/schema.py | 1 + 2 files changed, 6 insertions(+) diff --git a/fast_flights/core.py b/fast_flights/core.py index 977b241e..c8fab395 100644 --- a/fast_flights/core.py +++ b/fast_flights/core.py @@ -269,6 +269,10 @@ def safe(n: Optional[LexborNode]): # Get prices price = safe(item.css_first(".YMlIz.FpEdX")).text() or "0" + # Get flight number (from the flight details section) + # Flight numbers appear in spans like "F9 1230" or "UA 820" + flight_number = safe(item.css_first("span.Xsgmwe")).text(strip=True) or None + # Stops formatting try: stops_fmt = 0 if stops == "Nonstop" else int(stops.split(" ", 1)[0]) @@ -286,6 +290,7 @@ def safe(n: Optional[LexborNode]): "stops": stops_fmt, "delay": delay, "price": price.replace(",", ""), + "flight_number": flight_number, } ) diff --git a/fast_flights/schema.py b/fast_flights/schema.py index a5572d6d..950b67ef 100644 --- a/fast_flights/schema.py +++ b/fast_flights/schema.py @@ -21,3 +21,4 @@ class Flight: stops: int delay: Optional[str] price: str + flight_number: Optional[str] = None