I Built a Google Autocomplete Keyword Tool in Python (Source Code Included)
Source: Dev.to
Why Google Autocomplete?
Google Autocomplete is one of the most honest keyword datasets available.
- Every suggestion comes from real searches
- It reflects user intent
- It surfaces long‑tail queries early
Under the hood, most SEO tools call the same endpoint:
https://suggestqueries.google.com/complete/search
KeySage connects to it directly — no API, no authentication.
High‑Level Architecture
KeySage is a single‑process desktop app with a background scraping thread.
| Component | Technology |
|---|---|
| UI layer | Tkinter + ttkbootstrap |
| Networking | requests |
| Concurrency | threading + Event flags |
| Data model | set + defaultdict |
| Exports | TXT / CSV / JSON |
The goal was simplicity and hackability.
The Scraping Logic
Each base keyword goes through a configurable expansion pipeline:
- Base keyword input
- Optional prepend/append words
- Character expansion:
a–zanda–z + 0–9 - Google Autocomplete request
- Deduplication
- Live UI update
Example request
params = {
"client": "firefox",
"q": query,
"hl": language,
"gl": country
}
response = requests.get(
"https://suggestqueries.google.com/complete/search",
params=params
)
Results are streamed back to the UI using app.after() to keep Tkinter thread‑safe.
Threading Without Freezing the UI
Tkinter is single‑threaded, so scraping runs in a background thread.
Key patterns used:
threading.Thread(..., daemon=True)threading.Event()for safe cancellation- UI updates marshaled back to the main loop via
app.after()
This allows:
- Real‑time keyword output
- Instant cancellation
- No UI hangs
Rate Limiting & Stability
Google doesn’t love aggressive scraping. KeySage includes:
- Built‑in delays between requests
- Optional proxy support
- Stop‑safe execution at every loop
These measures keep the app usable without being reckless.
Automatic Keyword Clustering
After scraping, keywords are grouped by root word:
root = keyword.split()[0].lower()
clusters[root].append(keyword)
Clusters are preserved across all export formats.
Exporting Data (Developer‑Friendly)
Supported formats:
- TXT – human‑readable clusters
- CSV – SEO tools & spreadsheets
- JSON – automation & pipelines
Everything stays open and editable.
UI: Tkinter, But Not Ugly
The interface uses ttkbootstrap to avoid the default Tkinter look.
Features:
- Responsive layout
- Themed widgets
- Collapsible advanced settings
- Live scrolling output
- Built‑in help window
It’s intentionally minimal — no Electron, no web stack.
EXE vs Source Code
Three options are offered:
| Option | Price | Description |
|---|---|---|
| Windows EXE | $7 | Run instantly, no Python required |
| Full Source Code | $10 | Learn, modify, extend |
| EXE + Source | $12 | Best of both |
👉 Get KeySage here:
Why Release the Source Code?
Developers learn best from real tools — not toy examples. With the source you can:
- Add async requests
- Improve clustering
- Add new export formats
- Integrate other suggestion sources
- Turn it into a CLI or API
The project is meant to be a foundation.
Final Thoughts
KeySage isn’t trying to replace enterprise SEO platforms. It’s a transparent, hackable keyword tool built with:
- Python
- Common libraries
- Simple architecture
- No vendor lock‑in
If you want a practical example of a real‑world scraping + desktop app — or a tool you can actually use — this is for you.
👉 Buy / Download KeySage: