Last active
September 4, 2020 13:35
-
-
Save avinayak/2e513eadf4ffcbcc226ca4a7b9d9b870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import urllib.parse | |
import json | |
import random | |
import tweepy | |
que = ['why', 'how', 'why', 'how', 'why', 'how', 'why', 'how', | |
'what', 'who', 'can', 'is', 'will', 'could', 'would'] | |
def auto_query(que, word): | |
if word is not None: | |
return f"http://suggestqueries.google.com/complete/search?&output=firefox&gl=us&hl=en&q={que}%20{word}" | |
else: | |
return f"http://suggestqueries.google.com/complete/search?&output=firefox&gl=us&hl=en&q={que}" | |
def auto_result(data): | |
s = data | |
if isinstance(data[-1], dict): | |
s = data[:-1] | |
if len(s) >= 2: | |
s = s[1] | |
return s | |
def get_json(link): | |
with urllib.request.urlopen(link) as url: | |
pp = url.read().decode('latin-1').strip() | |
return json.loads(pp) | |
def tweet(msg): | |
# Authenticate to Twitter | |
auth = tweepy.OAuthHandler() | |
api = tweepy.API(auth) | |
api.update_status(msg) | |
def get_seed_phrase(): | |
f = open("pass.txt").read().splitlines() # from https://github.com/danielmiessler/SecLists/blob/master/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt | |
while True: | |
term = random.choice(f) | |
# print(term) | |
s = auto_result( | |
get_json(auto_query(random.choice(que), urllib.parse.quote(term)))) | |
if len(s) >= 1: | |
s = list(filter(lambda x: x.count(' ') > 1, s)) | |
s = list(filter(lambda x: 'pronounce' not in x.split(), s)) | |
s = list(filter(lambda x: 'mean' not in x.split(), s)) | |
s = list(filter(lambda x: 'say' not in x.split(), s)) | |
if len(s) >= 4: | |
s = s[len(s)//2:] | |
else: | |
s = [] | |
if len(s) >= 1: | |
print(term) | |
print("\n".join(s)) | |
p = random.choice(s) | |
return p | |
if __name__ == "__main__": | |
found = False | |
while not found: | |
seed = get_seed_phrase() | |
if len(seed.split(" ")) > 3: | |
trim_seed = " ".join(seed.split(" ")[0:3]) | |
print(trim_seed) | |
s = auto_result( | |
get_json(auto_query(urllib.parse.quote(trim_seed), None))) | |
s = list(filter(lambda x: x.count(' ') > 2, s)) | |
s = s[2:] | |
if len(s)>0: | |
found = True | |
tw = random.choice(s)+"?" | |
tweet(tw) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source for https://twitter.com/someonegoogled