Created
February 7, 2021 21:14
-
-
Save Romern/99db0ffc88015ffa6332780c51f608d9 to your computer and use it in GitHub Desktop.
Base function for the takeaway (lieferando) API. For the spec see https://github.com/TakeawayAPI/takeaway-spec
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
import requests | |
from hashlib import md5 | |
import json | |
import sys | |
headers = { | |
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', | |
"Accept": "application/json" | |
} | |
default_params = { | |
'language': 'de', | |
'version': '5.7', | |
'systemVersion': '24', | |
'appVersion': '4.15.3.2' | |
} | |
base_url = f'https://{default_params["language"]}.citymeal.com/android/android.php' | |
password = "4ndro1d" | |
def call_function(function, *params): | |
md5sum = md5() | |
md5sum.update(("".join([function] + [str(p) for p in params] + [password])).encode()) | |
req_params = default_params.copy() | |
req_params["var1"] = function | |
for i,v in enumerate(params): | |
req_params["var" + str(i+2)] = str(v) | |
req_params["var0"] = md5sum.hexdigest() | |
return requests.post(base_url, headers=headers, data=req_params).json() | |
#print(call_function("getdatafromgeolocation", 52, 6, 1)) | |
#print(json.dumps(call_function("getcountriesdata"))) | |
#print(json.dumps(call_function("getrestaurants", "52064", 2, "", "", "de"))) | |
if len(sys.argv)>2: | |
print(call_function(sys.argv[1], sys.argv[2:])) | |
else: | |
print(call_function(sys.argv[1])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment