Skip to content

Instantly share code, notes, and snippets.

@0ut0flin3
Last active October 15, 2023 00:49
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save 0ut0flin3/9bdbd0a1cf7e812038cc973c2c5bc78f to your computer and use it in GitHub Desktop.
Save 0ut0flin3/9bdbd0a1cf7e812038cc973c2c5bc78f to your computer and use it in GitHub Desktop.

Google has an amazing free API endpoint for text completions ,

below are some examples of the completions I got and the python code to interact with the API

Star this gist if this was helpful to you. Enjoy text completions

user@linux:$ python3 google_text_completion.py
 > hackers are
hackers are watching you
 > my hobbies are
my hobbies are travelling
import requests
import random
from fake_useragent import UserAgent
while True:
    
    url = "https://www.google.com/complete/search"
    params = {
        "client": "firefox",
        "hl": "en",
        "q": input(' > '),
        "output": "firefox"
    }

    response = requests.get(url, params=params, headers={
        "User-Agent": UserAgent().random,
        "Accept": "application/json",
        "Accept-Language": "en-US,en;q=0.5",
        "Referer": "https://www.google.com/",
        "Connection": "keep-alive",
        "TE": "Trailers"
    })
    suggestions = response.json()[1]

    print(random.choice(suggestions))
    ```
@saftoul
Copy link

saftoul commented Apr 29, 2023

Essaouira

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment