天天看點

分享淘寶時間伺服器同步時間接口api和蘇甯時間伺服器接口api

淘寶時間伺服器時間接口

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"}