Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # converting from CURL to REQUESTS: https://curl.trillworks.com/
- #
- import requests
- import datetime
- import pprint # pretty print
- #dt = datetime.datetime(2018, 6, 29, 6, 47, 40)
- dt = datetime.datetime.now()
- td_7mins = datetime.timedelta(minutes=7)
- dt = dt - td_7mins # now - 7 minutes
- #timestamp = "@timestamp:[{}.000Z TO *]".format(now.strftime("%Y-%m-%dT%H:%M:%S"))
- timestamp = dt.strftime("@timestamp:[%Y-%m-%dT%H:%M:%S.000Z TO *]")
- data = {
- "query": {
- "query_string": {
- "query": timestamp
- }
- },
- "size": 1000
- }
- print(data)
- url = "https://httpbin.org/get" # good for tests
- r = requests.get(url, json=data, headers=headers, verify=False, auth=('u_name', 'XXX'))
- pprint.pprint(r.json())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement