fix parsing of departures on some stations

- fix when there are several tables (js pagination?)
- fix when there are hints on bottom of tables
This commit is contained in:
Romain Bignon 2014-08-30 17:14:35 +02:00
commit 449ea03f68
4 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Julien Hébert, Romain Bignon # Copyright(C) 2010-2011 Julien Hébert, Romain Bignon
# Copyright(C) 2014 Benjamin Carton
# #
# This file is part of weboob. # This file is part of weboob.
# #

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Julien Hébert, Romain Bignon # Copyright(C) 2010-2011 Julien Hébert, Romain Bignon
# Copyright(C) 2014 Benjamin Carton
# #
# This file is part of weboob. # This file is part of weboob.
# #

View file

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Julien Hébert, Romain Bignon # Copyright(C) 2010-2011 Julien Hébert, Romain Bignon
# Copyright(C) 2014 Benjamin Carton
# #
# This file is part of weboob. # This file is part of weboob.
# #
@ -149,7 +150,7 @@ class DeparturesPage(HTMLPage):
@method @method
class get_departures(TableElement): class get_departures(TableElement):
head_xpath = u'//table[@class="etat_trafic"]/thead/tr/th[@scope="col"]/text()' head_xpath = u'//table[@class="etat_trafic"][1]/thead/tr/th[@scope="col"]/text()'
item_xpath = u'//table[@class="etat_trafic"]/tr' item_xpath = u'//table[@class="etat_trafic"]/tr'
col_type = u'Ligne' col_type = u'Ligne'
@ -162,7 +163,10 @@ class DeparturesPage(HTMLPage):
class item(ItemElement): class item(ItemElement):
klass = Departure klass = Departure
obj_time = DateTime(CleanText(TableCell('time')), LinearDateGuesser()) def condition(self):
return len(self.el.xpath('./td')) >= 6
obj_time = DateTime(CleanText(TableCell('time')))
obj_type = DepartureTypeFilter(TableCell('type')) obj_type = DepartureTypeFilter(TableCell('type'))
obj_departure_station = CleanText(Env('station')) obj_departure_station = CleanText(Env('station'))
obj_arrival_station = CleanText(TableCell('arrival')) obj_arrival_station = CleanText(TableCell('arrival'))

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon # Copyright(C) 2010-2014 Romain Bignon
# #
# This file is part of weboob. # This file is part of weboob.
# #
@ -31,7 +31,7 @@ class TransilienTest(BackendTest):
self.assertTrue(len(stations) > 0) self.assertTrue(len(stations) > 0)
def test_departures(self): def test_departures(self):
stations = list(self.backend.iter_station_search('aul')) stations = list(self.backend.iter_station_search('paris'))
self.assertTrue(len(stations) > 0) self.assertTrue(len(stations) > 0)
list(self.backend.iter_station_departures(stations[0].id)) list(self.backend.iter_station_departures(stations[0].id))