diff options
author | Christian Struck <christian@struck.se> | 2013-02-06 21:56:59 +0100 |
---|---|---|
committer | Christian Struck <christian@struck.se> | 2013-02-06 21:56:59 +0100 |
commit | a77bd63f6e87ab44e7bb797d36b8b87a6e42a9a5 (patch) | |
tree | c7284c47808914834f342a94b5495c58eecff150 | |
parent | 1ede09d2c27066f161e65aec0a309c9cdc32a54b (diff) | |
download | bvg-grabber-a77bd63f6e87ab44e7bb797d36b8b87a6e42a9a5.tar.gz bvg-grabber-a77bd63f6e87ab44e7bb797d36b8b87a6e42a9a5.tar.bz2 bvg-grabber-a77bd63f6e87ab44e7bb797d36b8b87a6e42a9a5.zip |
fixed a bug, where the application crashed.
-rw-r--r-- | bvggrabber/api/actualdeparture.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/bvggrabber/api/actualdeparture.py b/bvggrabber/api/actualdeparture.py index d4a3002..dd129b0 100644 --- a/bvggrabber/api/actualdeparture.py +++ b/bvggrabber/api/actualdeparture.py @@ -35,7 +35,7 @@ class ActualDepartureQueryApi(QueryApi): return Response(False, stationlist) else: # The station does not exist - return Response(False, []) + return Response(False) else: # The station seems to exist result = soup.find('div', {'id': '', @@ -45,18 +45,19 @@ class ActualDepartureQueryApi(QueryApi): rows = result.find_all('tr') departures = [] for row in rows: - td = row.find_all('td') - if td: - dep = Departure(start=self.station, - end=td[2].text.strip(), - when=td[0].text.strip(), - line=td[1].text.strip()) - departures.append(dep) + if row.parent.name == 'tbody': + td = row.find_all('td') + if td: + dep = Departure(start=self.station, + end=td[2].text.strip(), + when=td[0].text.strip(), + line=td[1].text.strip()) + departures.append(dep) return Response(True, self.station, departures) else: try: response.raise_for_status() except RequestException as e: - return Response(False, [], e) + return Response(False, error=e) else: - return Response(False, [], Exception("An unknown error occured")) + return Response(False, error=Exception("An unknown error occured")) |