added dpd tracking
@@ -19,6 +19,42 @@ class TrackerAPI:
return ""
+class DPD(TrackerAPI):
+ URL = "https://tracking.dpd.de/cgi-bin/simpleTracking.cgi?parcelNr={idcode}&type=1"
+
+ def __init__(self, idcode):
+ self.idcode = idcode
+ self.url = self.URL.format(idcode=self.idcode)
+
+
+ def status(self):
+ ret = {}
+ progress = "n/a"
+ status = "n/a"
+
+ with urlopen(self.url) as page:
+ page = page.read()
+ page = page.decode("UTF-8")
+ page = page[1:-1] # strip parenthesis of the data
+
+ try:
+ import json
+
+ data = json.loads(page)
+ status = data["TrackingStatusJSON"]["statusInfos"][0]["contents"][0]["label"]
+ except:
+ pass
+
+ ret["progress"] = progress
+ ret["status"] = status
+
+ return ret
+
+
+ def get_url(self):
+ return self.url
+
+
class DHL(TrackerAPI):
URL = "http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=en&idc={idcode}"
