curl post 请求 es 数据 REST 批量删除

 

curl  -d  "keyword=牛" http://api.com/path/index

 

curl模拟http发送get或post接口测试 - 一生守候 - 博客园 https://www.cnblogs.com/sunshine2016/p/6015976.html

 

 

import os
import json
import time
import re

l = ['标题网']
while True:
for kw in l:
curl = 'curl -d "keyword=牛" http://api.com/path/'.replace('牛', kw)
r = os.popen(curl)
info = r.readlines()
url_l = [i['url'] for i in json.loads(info[0]) if re.match('^.+ukwcn.com.+$', i['url']) is not None]
str_head = '{"delete":{"_id":"'
str_foot = '"}}'
# reg
ESdel_url_l = [str_head + i + str_foot for i in url_l]

'''
curl -XPOST 1.2.3.4:9200/twitter/_doc/_bulk --data-binary @$bulk_file >> $log_file
'''
ESdata_binary_f = 'ESdel_bulk_file' + str(int(time.time()))
ws = '\n'.join(ESdel_url_l)
with open(ESdata_binary_f, 'w', encoding="utf-8") as fw:
fw.write(ws)
ESdel_curl = 'curl -XPOST 1.2.3.4:9200/twitter/_doc/_bulk --data-binary @{} >> {}.log'.format(
ESdata_binary_f, ESdata_binary_f)
os.popen(ESdel_curl)
time.sleep(3)



posted @ 2018-09-07 15:32  papering  阅读(1535)  评论(0编辑  收藏  举报