Skip to content

Instantly share code, notes, and snippets.

@AlexDev404
Forked from 0ut0flin3/google_text_completion.md
Created October 15, 2023 00:49
Show Gist options
  • Save AlexDev404/768522da787a40040c2a7df6bdbf9418 to your computer and use it in GitHub Desktop.
Save AlexDev404/768522da787a40040c2a7df6bdbf9418 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))
    ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment