Python教程

python实现获取接口开始请求时间点

本文主要是介绍python实现获取接口开始请求时间点,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
url = "http://xxx.xxx.xxx/job/xxx_{}_xxx/xxx?".format(typename)
    headers = {
        'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15',
    }
    
    r = requests.get(url=url,headers=headers,params=params)
     h_content = r.headers
    # 获取接口请求时间
    tt = h_content['Date'].split(' ')
    d = tt[1]
    m = datetime.datetime.strptime(tt[2],'%b').month
    if len(str(m))==1:
        m = '0'+str(m)
    t_list = tt[4].split(':')
    h = int(t_list[0])+8
    M = t_list[1]
    s = t_list[2]
    t1 = str(m)+str(d)+str(h)+str(M)

    print(t1,s,r.elapsed.total_seconds())

 

这篇关于python实现获取接口开始请求时间点的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!