python获取苏宁服务器的毫秒级时间

效果

python获取苏宁服务器的毫秒级时间_第1张图片

代码

import requests
import datetime
while True:
    class Suningtime(object):
        r1 = requests.get(url='http://quan.suning.com/getSysTime.do',
                      headers={
     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36'})


        x = eval(r1.text)
        timeNum = int(x['sysTime1'])


        def funcname():
            timeStamp = float(Suningtime.timeNum) / 1000
            ret_datetime = datetime.datetime.utcfromtimestamp(timeStamp).strftime("%Y-%m-%d %H:%M:%S.%f")

            return ret_datetime

    t = Suningtime.funcname()
    print(t)

参考

python获取京东服务器的毫秒级时间
python获取淘宝服务器时间的代码

你可能感兴趣的:(python,python)