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())

 

上一篇:selenium 原理


下一篇:【Python网络爬虫】39健康网急诊科疾病爬取