Unofficial Python bindings to the Google search engine using Playwright. Not affiliated with Google.
Project description
Google Search (Playwright)
Google search from Python, powered by Playwright with automatic browser detection and interactive CAPTCHA solving.
Note: this project is not affiliated with Google in any way.
Why this fork?
Google's web search interface now requires JavaScript for most requests, which
broke the classic urllib + BeautifulSoup scraping used by the original
googlesearch library (pip install google). This package replaces that stack
with a real headless browser driven by Playwright, so it keeps working against
the current Google search experience.
It also auto-detects the browser already installed on your system (Chromium, Chrome, Edge, or Firefox) — no Playwright browser downloads required.
Installing
pip install google-search-playwright
Requirements
- Python 3.8+
- A Chromium, Chrome, Chrome-based (e.g. Microsoft Edge), or Firefox browser installed on your system.
The browser is found automatically. See find_browser() for the search order.
Usage example
from googlesearch import search
# Get the first 20 hits for: "Breaking Code" WordPress blog
for url in search('"Breaking Code" WordPress blog', stop=20):
print(url)
from googlesearch import search, lucky
# "I'm feeling lucky"
first = lucky('python programming')
print(first) # https://www.python.org/
CAPTCHA handling
If Google flags your IP and returns a CAPTCHA page, the library automatically opens a visible browser window so you can solve it interactively:
============================================================
Google requires a CAPTCHA verification. A visible browser
window has opened.
1. Solve the captcha in the browser.
2. When you see search results, return here and press Enter.
The search will then continue in the background using the
authenticated session.
============================================================
Press Enter after solving the captcha...
Once solved, the authenticated cookies are carried into the rest of the
headless session so subsequent requests succeed. A CAPTCHA prompt only
appears once per search; if it still fails afterward a ConnectionError
is raised.
Command-line usage
A google console script is provided:
google "python programming" --stop 5
google "linux kernel" --browser chromium
google "breaking news" --no-stealth
Run google --help for all options.
Browser auto-detection
The library searches in this order:
- Chromium/Chrome family via PATH:
chromium,chromium-browser,google-chrome,google-chrome-stable,chrome,chrom,microsoft-edge,edge. - Chromium/Chrome family at platform-specific paths (macOS
.appbundles, WindowsProgram Files). - Firefox via PATH:
firefox,firefox-esr,firefox-nightly. - Firefox at platform-specific paths.
You can override this with search(..., browser_type="firefox", exe_path="/path").
API reference
search(query, ...)— generator yielding result URLslucky(query, ...)— returns the first result URL as a stringget_tbs(from_date, to_date)— builds thetbsdate-range parameterfind_browser()— returns(browser_type, executable_path)orNone
Full Sphinx docs: https://google-search-playwright.readthedocs.io/en/latest/
License
BSD 3-Clause. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file google_search_playwright-4.0.2.tar.gz.
File metadata
- Download URL: google_search_playwright-4.0.2.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1313a540b3a6a12af5b69e7768b29c05ef5be20328c3ee0e94a53d704ec3c1a6
|
|
| MD5 |
634b79ad7f3a80eebccb3231d0514c93
|
|
| BLAKE2b-256 |
2a89fb62e2f732909cea242c7321603fdccf03d39259965b3a44645b7bfbda45
|
File details
Details for the file google_search_playwright-4.0.2-py3-none-any.whl.
File metadata
- Download URL: google_search_playwright-4.0.2-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56114d05e64ea6d491a42d135da37edeee57d2d4a48f3e10303736f44b84f078
|
|
| MD5 |
7267ce47d8d56df2cfbac3c78b817750
|
|
| BLAKE2b-256 |
1e3376c3f5dbfd16ef70b30470de9c4ee1c0eec3ade2c3b32247a31577e6d11d
|