import requests
import time
import hashlib
import os
import json
from contextlib import closing
import datetime def md5_passwd(str,salt=''):
str=str+salt
md = hashlib.md5()
md.update(str.encode())
res = md.hexdigest()
return res #get token
url = "https://api.xxx.com/auth/token"
appsecret="71fc0b31ab7945f2d0dcf5927db754ba"
appid="xxx"
ts=int(round(time.time() * ))
querystring = {"appid":"xxx","timestamp":ts,"sign":md5_passwd(appid+appsecret+str(ts))}
headers = {"Content-Type":"application/x-www-form-urlencoded",'cache-control': "no-cache"}
response = requests.post(url, headers=headers,data=querystring)
token_api=response.json()["data"]["token"] #get msg
headers["Authorization"]="Bearer "+token_api
url="https://api.xxx.com/openapi/robots/applications/versions/latest"
querystring = {"no":"xx-V1A1-00001","appkey":"HDb9aafb189b34b289","type":}
response = requests.get(url, headers=headers,params=querystring)
res=response.json()
file_url=res["data"]["url"]
file_v=res["data"]["version"]
print(res)