Created
November 16, 2017 14:16
-
-
Save olf42/851b12634148a76a9db2b38f87b6e262 to your computer and use it in GitHub Desktop.
Find GLS Packages if you only have a rough range/idea of the tracking ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
Find GLS Packages if you only have a rough range/idea of the tracking ID | |
""" | |
import requests | |
import datetime | |
import json | |
from time import sleep | |
# ENTER TRACKING RANGE BELOW ########################### | |
START = 000000000000 #12 digit int (lower limit) | |
END = 000000000001 # 12 digit int (upper limit) | |
# ENTER TRACKING RANGE ABOVE ########################### | |
SLEEP = 1 # in seconds between polling to not flood the server | |
PROGRESS_INTERVAL = 100 # every PROGRESS_INTERVAL ids a progess info is shown. | |
def make_millis(): | |
return int(datetime.datetime.now().timestamp()*1000) | |
def search_packages(start=START, | |
end=END, | |
sleep_amount=SLEEP, | |
progess=True, | |
progess_interval=PROGRESS_INTERVAL): | |
for package_id in range(start, end): | |
r = requests.get("https://gls-group.eu/app/service/open/rest/DE/de/rstt001?match={0}&caller=witt002&milis={1}".format(package_id, make_millis())) | |
if r.status_code != 404: | |
print(package_id) | |
# Show address / depot info | |
try: | |
print(json.dumps(json.loads(r.text)['tuStatus'][0]['history'][0]["address"])) | |
except: | |
pass | |
# Show some kind of progess info | |
if progess: | |
if package_id%progess_interval == 0: | |
print("\nState: {}\n".format(package_id)) | |
sleep(sleep_amount) | |
if __name__ == "__main__": | |
search_packages() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment