def track(number):
    """Request tracking company about package status.

    :param number: package number in tracking company
    :return: Package status
    """

    r = requests.post(
        "https://poland.fedex.com/domestic-shipping/pub/tracktrace.do",
        data={'packageId': number})

    d = pq(r.text)
    table = d('table.customContentable').eq(0)
    status = 'TRANSIT'
    events = []

    for row in table('tr').items():
        if row.has_class('customContentTableRowOdd') or row.has_class(
                'customContentTableRowEven'):
            stage = [t.text() for t in row('td').items()]
            stage_date = dateparser.parse("%s" % (stage[0]),
                                          settings={'DATE_ORDER': 'YMD'})
            events.append(
                trackingEvent(time=stage_date, place=stage[2],
                              status=stage[1]))
            if re.search("Kurier doręczył przesyłkę do odbiorcy", stage[1]):
                status = "DELIVERED"

    if len(events) > 0:
        return trackingStatus(number, ID, status, events)
    else:
        return trackingStatus(number, ID, 'NOTFOUND', [])
Beispiel #2
0
def track(number):
    """Request tracking company about package status.

    :param number: package number in tracking company
    :return: Package status
    """

    payload = {'match': number}

    r = requests.get(
        "https://gls-group.eu/app/service/open/rest/PL/pl/rstt001",
        params=payload)
    status = 'TRANSIT'

    if r.status_code == 200:

        data = json.loads(r.text)
        if 'lastError' in data:
            return trackingStatus(number, ID, 'NOTFOUND', [])
        else:
            tracking = data['tuStatus'][0]['history']
            events = []
            for row in tracking:
                stage_date = dateparser.parse("{} {}".format(
                    row['date'], row['time']),
                                              settings={'DATE_ORDER': 'YMD'})
                events.append(
                    trackingEvent(time=stage_date,
                                  place=row['address']['city'],
                                  status=row['evtDscr']))
                if re.search("Paczka doreczona", row['evtDscr']):
                    status = "DELIVERED"
            return trackingStatus(number, ID, status, events)
    else:
        return trackingStatus(number, ID, 'NOTFOUND', [])
Beispiel #3
0
def track(number):
    r = requests.get(
        "https://webapps.dhl.com.pl/app/tnt/old_cr_sn.aspx?SN=%s" % number,
        headers={
            'User-agent':
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
        })
    d = pq(r.text)
    table = d('table#shipment-details-hdr-table')
    i = 0
    events = []
    status = "TRANSIT"

    for row in table('tr').items():
        if i > 0:
            l = [t.text() for t in row('td').items()]
            d = dateparser.parse("%s %s" % (l[0], l[1]),
                                 settings={'DATE_ORDER': 'DMY'})
            l[1] = d
            events.append(trackingEvent(l[1], l[2], l[3]))
            if re.search("doręczona do Odbiorcy", l[3]):
                status = "DELIVERED"
        i = i + 1

    if len(events) > 0:
        return trackingStatus(number, ID, status, events[::-1])
    else:
        return trackingStatus(number, ID, 'NOTFOUND', [])
Beispiel #4
0
def track(number):
    """Request tracking company about package status.

    :param number: package number in tracking company
    :return: Package status
    """

    payload = {
        'con': number,
        'locale': 'pl_PL',
        'searchType': 'CON'
    }

    r = requests.get("https://www.tnt.com/api/v1/shipment", params=payload)
    status = 'TRANSIT'

    if r.status_code == 200:

        data = json.loads(r.text)
        if 'notFound' in data['tracker.output']:
            return trackingStatus(number, ID, 'NOTFOUND', [])
        else:
            tracking = data['tracker.output']['consignment'][0]['statusData']

            events = []
            for row in tracking:
                stage_date = dateparser.parse("{} {}".format(row['localEventDate'], row['localEventTime']), settings={'DATE_ORDER': 'YMD'})
                events.append(trackingEvent(time=stage_date, place=row['depot'], status=row['statusDescription']))
                if re.search("Przesyłka dostarczona", row['statusDescription']):
                    status = "DELIVERED"
            return trackingStatus(number, ID, status, events)
    else:
            return trackingStatus(number, ID, 'NOTFOUND', [])
Beispiel #5
0
def track(number):

    r = requests.post(
        "https://tracktrace.dpd.com.pl/findPackage",
        headers={
            'Referer':
            "https://tracktrace.dpd.com.pl/parcelDetails?p1=%s" % number,
            'User-agent':
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
            'Origin': "https://tracktrace.dpd.com.pl"
        },
        data={
            'q': number,
            'typ': 1
        })

    d = pq(r.text)
    table = d('table.table-track')
    events = []
    status = 'TRANSIT'

    for row in table('tr').items():
        l = [t.text() for t in row('td').items()]
        d = dateparser.parse("%s %s" % (l[0], l[1]),
                             settings={'DATE_ORDER': 'YMD'})
        events.append(trackingEvent(d, OFFICES.get(l[3], l[3]), l[2]))
        if re.search("Przesyłka doręczona", l[2]):
            status = "DELIVERED"
    if len(events) > 0:
        return trackingStatus(number, ID, status, events)
    else:
        return trackingStatus(number, ID, 'NOTFOUND', [])
Beispiel #6
0
def track(number):

    r = requests.get("http://emonitoring.poczta-polska.pl/")

    cookies = r.cookies
    session_id = r.cookies['PHPSESSID']

    r = requests.post(
        "http://emonitoring.poczta-polska.pl/wssClient.php",
        headers={
            'Referer':
            "http://emonitoring.poczta-polska.pl/",
            'User-agent':
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
        },
        data={
            'n': number,
            's': session_id
        },
        cookies=cookies)

    d = pq(r.text)
    table = d('table#zadarzenia_td')
    events = []
    status = "TRANSIT"

    i = 0

    for row in table('tr').items():
        if i > 0:
            l = [t.text() for t in (row('td').items())]
            adr = row('td a.jedn').attr('title')

            if adr and '|' in adr:
                l.append(', '.join(adr.split('|')[0:2]))

            if l:
                d = dateparser.parse(l[1], settings={'DATE_ORDER': 'YMD'})
                if len(l) == 4:
                    l[2] = "%s - %s" % (l[2], l[3])
                events.append(trackingEvent(d, l[2], l[0]))
                if re.search("(Odebrano|Doręczono)", l[0]):
                    status = "DELIVERED"
        i = i + 1

    if len(events) > 0:
        return trackingStatus(number, ID, status, events[::-1])
    else:
        return trackingStatus(number, ID, 'NOTFOUND', [])
Beispiel #7
0
def track(number):

    r = requests.get(
        "https://api-shipx-pl.easypack24.net/api/v1/history/package[0]=%s?_=%d"
        % (number, time.time() * 1000.0),
        headers={
            'Referer':
            "https://inpost.pl/pl/pomoc/znajdz-przesylke?parcel=%s" % number,
            'User-agent':
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
            'Origin': "https://inpost.pl"
        },
    )
    data = json.loads(r.text)

    try:
        maxstatus = int(data['maxStatusCode'][5:])
    except:
        return trackingStatus(number, ID, 'NOTFOUND', [])
    events = []
    status_ = 'TRANSIT'

    for event in range(maxstatus + 1):
        if 'index%d' % event in data['history']:
            row = data['history']['index%d' % event]
            office = ''
            if row['pl'].startswith('Przyjęta w oddziale InPost - '):
                office = row['pl'][29:]
                status = row['pl'][0:26]
            else:
                office = ""
                status = row['pl']
            d = dateparser.parse(row['changeDate'],
                                 settings={'DATE_ORDER': 'YMD'})
            print(row)
            events.append(trackingEvent(d, office, status))
            if re.search("Doręczono", status):
                status_ = "DELIVERED"

    if len(events) > 0:
        return trackingStatus(number, ID, status_, events[::-1])
    else:
        return trackingStatus(number, ID, 'NOTFOUND', [])
Beispiel #8
0
def track(number):
    """Request tracking company about package status.

    :param number: package number in tracking company
    :return: Package status
    """

    r = requests.post("https://wwwapps.ups.com/WebTracking/track",
                      data={
                          'trackNums': number,
                          'loc': 'pl_PL',
                          'track.x': 'Monitoruj'
                      })

    d = pq(r.text)
    table = d('table.dataTable')
    status = 'TRANSIT'
    events = []
    for x, row in enumerate(table('tr').items()):
        if x > 0:

            stage = []
            for t in row('td').items():
                td = t.text()
                td = td.translate({ord(c): None for c in '\n\t\r'})
                td = re.sub(r'\s+', ' ', td)
                stage.append(td)

            stage_date = dateparser.parse("{} {}".format(stage[1], stage[2]),
                                          settings={'DATE_ORDER': 'YMD'})
            events.append(
                trackingEvent(time=stage_date, place=stage[0],
                              status=stage[3]))
            if re.search("Doręczono", stage[3]):
                status = "DELIVERED"
    if len(events) > 0:
        return trackingStatus(number, ID, status, events)
    else:
        return trackingStatus(number, ID, 'NOTFOUND', [])
Beispiel #9
0
def track(number):
    
    r = requests.get("http://www.dhl.com.pl/shipmentTracking?AWB=%s&countryCode=pl&languageCode=pl" % number)
    data = json.loads(r.text)


    if data.get('errors'):
        return trackingStatus(number, ID, 'NOTFOUND', [])
        

    events = []
    status_ = 'TRANSIT'

    for event in data['results'][0]['checkpoints']:
        d = dateparser.parse("%s %s" % (event['date'], event['time']), settings={'DATE_ORDER': 'DMY'})
        events.append(trackingEvent(d, event['location'].rstrip(), event['description']))
        if re.search("Przesyłka doręczona", event['description'] ): 
            status_ = "DELIVERED"

    if len(events) > 0:
        return trackingStatus(number, ID, status_, events)
    else:
        return trackingStatus(number, ID, 'NOTFOUND', [])