灏忎唬鐮?--http璇锋眰淇℃伅鍐欏叆鏂囦欢

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了灏忎唬鐮?--http璇锋眰淇℃伅鍐欏叆鏂囦欢相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/arc' title='arc'>arc   __name__   ali   xxxxx   http   end   pos   info   day   

python3鐗堟湰

 

 

import datetime
import requests
import os
import time

log_name="client-quality.log"

def appendStrToFile(filePath, string):
with open(filePath, "ab") as f:
f.write(string)

def create_log_file(filePath):
if os.path.exists(filePath):
os.remove(filePath)
f = open(filePath, 鈥榳鈥?
f.close()

if __name__ == 鈥榑_main__鈥?
create_log_file(log_name)
for i in range(10000):
time_now = datetime.datetime.now()
appendStrToFile(log_name,str.encode(time_now.strftime("%Y-%m-%d %H:%M:%S") + 鈥榎n鈥?)
time_to = (time_now+datetime.timedelta(minutes=-5)).strftime("%Y-%m-%d %H:%M:%S")
time_from = (time_now+datetime.timedelta(days=-14,minutes=-5)).strftime("%Y-%m-%d %H:%M:%S")

url1 = "http://ip/xxx/api/v1/search_info?server_zone=internal"
body_profile =鈥榹"time":["鈥? time_from +鈥?,"鈥? time_to +鈥?],"xxxxx":"memory","xxxx":[0,1,2],"xxxx":"avg"}鈥?br /> r=requests.post(url1, data=body_profile)
#print(r.text)
log=url1+": "+str(r.elapsed.total_seconds())+" "
appendStrToFile(log_name,str.encode(log))
#print(r.elapsed.total_seconds())

以上是关于灏忎唬鐮?--http璇锋眰淇℃伅鍐欏叆鏂囦欢的主要内容,如果未能解决你的问题,请参考以下文章

odoo 瀵煎叆鏂囦欢xml鍒朵綔,浣跨敤csv 鏂囦欢鍒朵綔xml 鏂囦欢

Jquery.form寮傛涓婁紶鏂囦欢甯歌闂瑙e喅

linux鍘嬬缉瑙e帇鏂囦欢

銆€iOS 缃戠粶璇锋眰缂撳瓨锛歂SURLCache璇﹁В

鍏充簬HTTP璇锋眰

c#妯℃嫙Http璇锋眰