-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheinschreiben
executable file
·27 lines (22 loc) · 1.04 KB
/
einschreiben
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
set -eo pipefail
[[ -z $1 ]] || [[ -z $2 ]] && echo "Usage $(basename ${0}) <tracking_no> <DD.MM.YYYY>" && exit 1
data=$(curl -s "https://www.deutschepost.de/int-verfolgen/data/shipment?language=de" \
-H 'authority: www.deutschepost.de' \
-H 'accept: application/json' \
-H 'accept-language: en-US,en;q=0.9,de;q=0.8' \
-H 'content-type: application/json' \
-H 'referer: https://www.deutschepost.de/de/s/sendungsverfolgung.html' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
--data-raw "{\"piececode\":\"${1}\", \"postedDate\":\"${2}\"}" \
--compressed)
if [[ $3 == "--debug" ]]; then
echo "${data}" | jq .
else
echo "${data}" | jq -r '.sendungen[] | "Status: " + (.sendungsdetails.sendungsverlauf.aktuellerStatus) +
(if (.sendungsdetails.sendungsverlauf.events? | length) > 0 then
("\nHistory:\n" + (.sendungsdetails.sendungsverlauf.events | map("- " + .status) | join("\n")))
else
""
end)'
fi