Skip to content

Commit 7a71523

Browse files
committed
flights: stop tracking flights for invalid flight numbers
an entry with an invalid number would cause other flights to not get tracked
1 parent fb59946 commit 7a71523

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

flights.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ def _iter_flight_rows(rs: requests.Session, number: str) -> typing.Iterator[bs4.
139139
response = rs.get('https://www.flightradar24.com/data/flights/' + number)
140140
response.raise_for_status()
141141
soup = bs4.BeautifulSoup(response.content, 'lxml')
142-
yield from soup.find('table', id='tbl-datatable').find('tbody').find_all('tr', class_='data-row')
142+
if (table := soup.find('table', id='tbl-datatable')) is None:
143+
return
144+
yield from table.find('tbody').find_all('tr', class_='data-row')
143145

144146
@dataclasses.dataclass(eq=False, slots=True)
145147
class FlightState:

0 commit comments

Comments
 (0)