方法一:
from elasticsearch import Elasticsearch
import os
es = Elasticsearch(['localhost'], http_auth=('', ''), port=9273, timeout=50000)
def write_start_data(time_, time_list, month, file_name, iptvaccount):
write_fact_path = "E:\\公司\\案例数据采集\\olt告警案例分析\\{0}\\{1}_{2}.txt".format(time_, iptvaccount, file_name)
f = open(write_fact_path, "w")
for key, value in time_list.items():
start = key.format(day, start_hour, month, end_hour)
end = value.format(day, start_hour, month, end_hour)
hour_min = start.split()[1]
if hour_min == "23:55":
end = value.format(day_next,start_hour,month,end_hour)
rs = get_iptv_monitor_start_data(time_, start, end, iptvaccount)
for hit in rs['hits']['hits']: