Exemplo n.º 1
0
 def parse_checkpoint(checkpoint):
     status = checkpoint['status']
     time = checkpoint['date'].replace('-', '/') \
         + ' στις ' + checkpoint['time']
     space = checkpoint['place']
     return TrackingCheckpoint(
         status, time, space,
         format_timestamp(
             datetime.strptime(
                 checkpoint['date'] + ' ' + checkpoint['time'],
                 '%d-%m-%Y %H:%M')))
Exemplo n.º 2
0
        def parse_checkpoint(checkpoint):
            timestamp = datetime.strptime(
                checkpoint.contents[3].contents[0][:-3], '%d/%m/%Y %H:%M:%S')
            date = timestamp.strftime('%d/%m/%Y στις %H:%M')
            description = str(checkpoint.contents[5].contents[0])
            location = checkpoint.contents[7].contents[0]
            if isinstance(location, element.Tag):
                # The last location update on a delivered package is a hyperlink, so I need to get only the text from it
                location = str(location.contents[0])

            return TrackingCheckpoint(description, date, location,
                                      format_timestamp(timestamp))
Exemplo n.º 3
0
        def parse_checkpoint(checkpoint: BeautifulSoup):
            items = checkpoint.find("span", {
                "class": "font-small-3"
            }).contents[0].split(", ")
            timestamp = datetime.strptime(items[1], "%d/%m/%Y στις %H:%M")
            date = items[1]
            location = items[0]
            description = checkpoint.find("h4", {
                "class": "card-title"
            }).contents[0].text

            return TrackingCheckpoint(description, date, location,
                                      format_timestamp(timestamp))
Exemplo n.º 4
0
        def parse_checkpoint(checkpoint):
            timestamp = checkpoint['createdAt'][:-5]
            tdate = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S')
            date = tdate.strftime('%d/%m/%Y στις %H:%M')
            try:
                location = checkpoint['driver']['city']
            except KeyError:
                location = "Unknown"
            status = checkpoint['description']

            return TrackingCheckpoint(
                status, date, location,
                format_timestamp(
                    datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S')))
Exemplo n.º 5
0
        def parse_checkpoint(checkpoint):
            details = checkpoint.find_all("td")
            dt = details[1].text
            dt = dt.replace(
                'μ.μ.', 'PM'
            )  # They are using 12-hour format so I have to specify AM / PM
            dt = dt.replace('π.μ.', 'AM')

            try:
                timestamp = datetime.strptime(dt, ' %d/%m/%y, %I:%M %p ')
            except ValueError:  # No idea why, but sometimes this breaks
                timestamp = datetime.now(
                )  # This can't be left empty, so for now I'm putting he current time until a better solution can be found

            date = timestamp.strftime('%d/%m/%Y, %H:%M')
            return TrackingCheckpoint(details[2].text, date, details[0].text,
                                      format_timestamp(timestamp))
Exemplo n.º 6
0
        def parse_checkpoint(checkpoint: BeautifulSoup):
            description = checkpoint.find(
                attrs={"class": "checkpoint-status"}).get_text().replace('Κατάσταση', '')
            description = description.replace('Status', '').strip()

            date = checkpoint.find(
                attrs={"class": "checkpoint-date"}).get_text().replace('Ημερομηνία', '')
            date = date.split(',')[-1].strip()
            dtime = checkpoint.find(
                attrs={"class": "checkpoint-time"}).get_text().replace('Ώρα', '')
            dtime = dtime.replace('Time', '')
            date = date + ' στις ' + dtime
            timestamp = datetime.strptime(date, '%d/%m/%Y στις %H:%M')

            location = checkpoint.find(attrs={"class": "checkpoint-location"})
            if location is not None:
                location = location.get_text().replace('Τοποθεσία', '')
            else:
                location = ""
            
            location = location.replace("Location", "")

            return TrackingCheckpoint(description, date, location, format_timestamp(timestamp))