From 2d00d20888b47a21848a0ce36ba8331560b60d93 Mon Sep 17 00:00:00 2001 From: Christian Struck Date: Tue, 29 Jan 2013 17:47:29 +0100 Subject: fixed a bug where not all buses are parsed. --- bvggrabber/api/actualdeparture.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'bvggrabber') diff --git a/bvggrabber/api/actualdeparture.py b/bvggrabber/api/actualdeparture.py index f6f5fe2..e4c3c26 100644 --- a/bvggrabber/api/actualdeparture.py +++ b/bvggrabber/api/actualdeparture.py @@ -38,18 +38,19 @@ class ActualDepartureQueryApi(QueryApi): return (False, []) else: # The station seems to exist - tbody = soup.find('tbody') - if tbody is None: + result = soup.find('div', {'id': '', 'class': 'ivu_result_box'}) + if result is None: return (False, []) - rows = tbody.find_all('tr') + rows = result.find_all('tr') departures = [] for row in rows: - tds = row.find_all('td') - dep = Departure(start=self.station_enc, - end=tds[2].text.strip(), - when=tds[0].text.strip(), - line=tds[1].text.strip()) - departures.append(dep) + td = row.find_all('td') + if td: + dep = Departure(start=self.station_enc, + end=td[2].text.strip(), + when=td[0].text.strip(), + line=td[1].text.strip()) + departures.append(dep) return (True, departures) else: response.raise_for_status() -- cgit v1.2.3