Exemple #1
0
    def get_roadmap(self):
        roadstep = None
        for step in self.doc.xpath(
                '(//ol[@class="trajet_feuilleDeRoute transport"])[1]/li'):
            if step.attrib and 'class' in step.attrib and step.attrib[
                    'class'] == 'odd':

                if roadstep:
                    roadstep.end_time = Time(
                        CleanText('./div/div[has-class("temps")]'))(step)
                    roadstep.arrival = CleanText(
                        './div/div/div/div[@class="step_infos clearfix"]',
                        default=None)(step)

                    yield roadstep

                roadstep = RoadStep()
                roadstep.start_time = Time(
                    CleanText('./div/div[has-class("temps")]'))(step)
                roadstep.departure = CleanText(
                    './div/div/div/div[@class="step_infos clearfix"]',
                    default=None)(step)

            if not step.attrib:
                roadstep.line = CleanText('./div/div/div/div/div/div[@class="transport"]', default=None)(step) or\
                                CleanText('./div/div/div/div[@class="step_infos clearfix"]', default=None)(step) or\
                                Join('\n', './div/div/div/div/div/ul/li/text()')(step)

                roadstep.duration = RoadMapDuration(
                    CleanText('./div/div[has-class("temps")]'))(step)

        del roadstep
Exemple #2
0
    def iter_roadmap(self, departure, arrival, filters):
        with self.browser:
            roadmap = self.browser.get_roadmap(departure, arrival, filters)

        for s in roadmap['steps']:
            step = RoadStep(s['id'])
            step.line = s['line']
            step.start_time = s['start_time']
            step.end_time = s['end_time']
            step.departure = s['departure']
            step.arrival = s['arrival']
            step.duration = s['duration']
            yield step
 def get_roadmap(self):
     for step in self.doc.xpath('//table[@class="trajet_etapes"]/tr[@class="etape"]'):
         roadstep = RoadStep()
         roadstep.line = '%s %s' % (DepartureTypeFilter(step.xpath('./td[@class="moyen"]'))(self),
                                    CleanText('./td[@class="moyen"]')(step))
         roadstep.start_time = DateTime(CleanText('./th/span[@class="depart"]'),
                                        LinearDateGuesser())(step)
         roadstep.end_time = DateTime(CleanText('./th/span[@class="depart"]/following-sibling::span'),
                                      LinearDateGuesser())(step)
         roadstep.departure = CleanText('./td[@class="arret"]/p/strong')(step)
         roadstep.arrival = CleanText('./td[@class="arret"]/p/following-sibling::p/strong')(step)
         roadstep.duration = RoadMapDuration(CleanText('./td[@class="time"]'))(step)
         yield roadstep
Exemple #4
0
 def get_roadmap(self):
     for step in self.doc.xpath(
             '//table[@class="trajet_etapes"]/tr[@class="etape"]'):
         roadstep = RoadStep()
         roadstep.line = '%s %s' % (DepartureTypeFilter(
             step.xpath('./td[@class="moyen"]'))(self),
                                    CleanText('./td[@class="moyen"]')(step))
         roadstep.start_time = DateTime(
             CleanText('./th/span[@class="depart"]'),
             LinearDateGuesser())(step)
         roadstep.end_time = DateTime(
             CleanText(
                 './th/span[@class="depart"]/following-sibling::span'),
             LinearDateGuesser())(step)
         roadstep.departure = CleanText('./td[@class="arret"]/p/strong')(
             step)
         roadstep.arrival = CleanText(
             './td[@class="arret"]/p/following-sibling::p/strong')(step)
         roadstep.duration = RoadMapDuration(
             CleanText('./td[@class="time"]'))(step)
         yield roadstep
Exemple #5
0
    def get_roadmap(self):
        roadstep = None
        for step in self.doc.xpath('(//ol[@class="trajet_feuilleDeRoute transport"])[1]/li'):
            if step.attrib and 'class' in step.attrib and step.attrib['class'] == 'odd':

                if roadstep:
                    roadstep.end_time = Time(CleanText('./div/div[has-class("temps")]'))(step)
                    roadstep.arrival = CleanText('./div/div/div/div[@class="step_infos clearfix"]', default=None)(step)

                    yield roadstep

                roadstep = RoadStep()
                roadstep.start_time = Time(CleanText('./div/div[has-class("temps")]'))(step)
                roadstep.departure = CleanText('./div/div/div/div[@class="step_infos clearfix"]', default=None)(step)

            if not step.attrib:
                roadstep.line = CleanText('./div/div/div/div/div/div[@class="transport"]', default=None)(step) or\
                                CleanText('./div/div/div/div[@class="step_infos clearfix"]', default=None)(step) or\
                                Join('\n', './div/div/div/div/div/ul/li/text()')(step)

                roadstep.duration = RoadMapDuration(CleanText('./div/div[has-class("temps")]'))(step)

        del roadstep