Metadata-Version: 2.4
Name: google-search-playwright
Version: 4.0.2
Summary: Unofficial Python bindings to the Google search engine using Playwright. Not affiliated with Google.
Author-email: SkillfulElectro <electromutex@gmail.com>
License: BSD-3-Clause
Project-URL: Homepage, https://github.com/SkillfulElectro/google-search-playwright
Project-URL: Source, https://github.com/SkillfulElectro/google-search-playwright
Project-URL: Documentation, https://google-search-playwright.readthedocs.io/en/latest/
Project-URL: Issues, https://github.com/SkillfulElectro/google-search-playwright/issues
Keywords: google,search,playwright,web,scraping
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Environment :: Console
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: playwright>=1.40
Dynamic: license-file

# 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

```python
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)
```

```python
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:

```bash
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:

1. **Chromium/Chrome family** via PATH: `chromium`, `chromium-browser`,
   `google-chrome`, `google-chrome-stable`, `chrome`, `chrom`,
   `microsoft-edge`, `edge`.
2. Chromium/Chrome family at platform-specific paths (macOS `.app` bundles,
   Windows `Program Files`).
3. **Firefox** via PATH: `firefox`, `firefox-esr`, `firefox-nightly`.
4. Firefox at platform-specific paths.

You can override this with `search(..., browser_type="firefox", exe_path="/path")`.

## API reference

- `search(query, ...)` — generator yielding result URLs
- `lucky(query, ...)` — returns the first result URL as a string
- `get_tbs(from_date, to_date)` — builds the `tbs` date-range parameter
- `find_browser()` — returns `(browser_type, executable_path)` or `None`

Full Sphinx docs: https://google-search-playwright.readthedocs.io/en/latest/

## License

BSD 3-Clause. See `LICENSE`.
