Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- # -*- coding: utf-8 -*-
- import requests
- import random
- from requests.packages.urllib3.exceptions import InsecureRequestWarning
- requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
- url = "https://my.elastic.co/elastic/year-2016/_search"
- def es_get(word):
- search_url = url + "?size=100" + "&q=post_content:" + word
- content = requests.get(
- search_url,
- verify=False,
- auth=("es_user", "es_pass")
- )
- return str(content.status_code)
- words = "Vedci v USA si myslia že imigračný a cestovný zákaz prezidenta Donalda Trumpa poškodí vedu a pokrok v oblasti výskumu Tisíce z nich preto podpísali petíciu proti Trumpovi"
- words = words.split(" ")
- for word in words:
- word = random.choice(words)
- rand_string1 = word + " " + random.choice(words)
- rand_string2 = word + " " + random.choice(words)
- rand_string3 = word + " " + random.choice(words)
- rand_string4 = random.choice(words) + random.choice(words)
- print( es_get(rand_string1) + " 1 : " + rand_string1 )
- print( es_get(rand_string2) + " 2 : " + rand_string2 )
- print( es_get(rand_string3) + " 3 : " + rand_string3 )
- print( es_get(rand_string4) + " 4 : " + rand_string4 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement