淘寶時間伺服器時間介面 http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp Python獲取淘寶時間伺服器時間示例 ...
最近要開發一款搶購秒殺的小工具,需要同步系統時間,這裡分享兩個時間伺服器介面api給大家:
1.淘寶時間伺服器時間介面
http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp
返回json數據
{"api":"mtop.common.getTimestamp","v":"*","ret":["SUCCESS::介面調用成功"],"data":{"t":"1586519130440"}}
Python獲取淘寶時間伺服器時間示例
1 import requests 2 import time 3 4 class timeTaobao(object): 5 r1 = requests.get(url='http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp', 6 headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4098.3 Safari/537.36'}) 7 x = eval(r1.text) 8 timeNum = int(x['data']['t']) 9 10 def funcname(): 11 timeStamp = float(timeTaobao.timeNum/1000) 12 timeArray = time.localtime(timeStamp) 13 otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray) 14 return otherStyleTime 15 16 t = timeTaobao.funcname() 17 print(t)
2.蘇寧時間伺服器介面api:
http://quan.suning.com/getSysTime.do
返回json數據
{"sysTime2":"2020-04-10 19:46:50","sysTime1":"20200410194650"}