Registry / http-networking / google-search-results

google-search-results

JSON →
library2.4.2pypypi✓ verified 22d ago

The `google-search-results` Python package (version 2.4.2) is a client library designed to scrape and parse localized search results from various engines like Google, Bing, Baidu, Yahoo, Yandex, eBay, and more, by utilizing the SerpApi.com service. While functional, it is now considered a 'legacy' SerpApi module, with the actively maintained and recommended client being the `serpapi` package. Its last update was March 2023.

pip install google-search-results
INSTALL
IMPORT
SIG · GOOGLE-SEARCH-RESU
G
google-search-results
http-networkingpythonv2.4.2
Install
3.0s avg
Import
357ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.4.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.368s · 22.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.0s · import 0.346s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GoogleSearch
from serpapi import GoogleSearch
from google_search_results import GoogleSearch
The `google-search-results` package exposes its main class under the `serpapi` namespace, not its own package name, which can be confusing given there is a separate, recommended `serpapi` library.

This quickstart demonstrates how to perform a basic Google search using the `google-search-results` library, fetching results for 'coffee' in Austin, Texas. It retrieves the SerpApi key from an environment variable for security and best practice.

import os from serpapi import GoogleSearch # Ensure your SerpApi key is set as an environment variable, e.g., SERPAPI_API_KEY api_key = os.environ.get('SERPAPI_API_KEY', '') if not api_key: print("Error: SERPAPI_API_KEY environment variable not set.") else: params = { "q": "coffee", "location": "Austin, Texas", "hl": "en", "gl": "us", "api_key": api_key } try: search = GoogleSearch(params) results = search.get_dict() if 'organic_results' in results: for result in results['organic_results']: print(f"Title: {result.get('title')}\nLink: {result.get('link')}\n") else: print("No organic results found.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingThe `google-search-results` package is considered a legacy wrapper for SerpApi. The official and actively maintained Python client is now the `serpapi` package (pip install serpapi), which offers more features and better support.
fix
Migrate to the `serpapi` package. Replace `from serpapi import GoogleSearch` with `import serpapi` and use `client = serpapi.Client(api_key=os.getenv('SERPAPI_API_KEY'))` then `client.search({'q': 'query'})`.
affects: <=2.4.2
gotchaDespite being installed as `google-search-results`, the primary class is imported from the `serpapi` namespace (`from serpapi import GoogleSearch`). This can cause confusion with the newer, separate `serpapi` package.
fix
Be mindful of the import path. For `google-search-results`, always use `from serpapi import GoogleSearch`. For the newer, recommended client, install `serpapi` and use `import serpapi`.
affects: All versions of `google-search-results`
gotchaAlways manage your SerpApi key securely using environment variables (e.g., `SERPAPI_API_KEY`) instead of hardcoding it in your scripts.
fix
Set your API key as an environment variable: `export SERPAPI_API_KEY='YOUR_API_KEY'`. Access it in Python using `os.environ.get('SERPAPI_API_KEY')`.
affects: All versions
gotchaSerpApi uses standard HTTP response codes. Unsuccessful requests will raise `serpapi.HTTPError` or `serpapi.TimeoutError` exceptions (from the underlying `serpapi` library components or the new `serpapi` client). Common errors include 401 (Unauthorized - invalid API key), 429 (Too Many Requests - rate limit or out of searches).
fix
Implement robust try-except blocks to catch `serpapi.HTTPError` and `serpapi.TimeoutError`. Check error messages and HTTP status codes for detailed diagnostics.
affects: All versions
deprecatedAs of September 2025, SerpApi discontinued support for the Google Product API endpoint. Users scraping product page views should migrate to the Google Immersive Product API.
fix
Review your API parameters. If you were using the deprecated Google Product API, switch to using the Google Immersive Product API or its equivalent within SerpApi's offerings.
affects: All versions of `google-search-results` when querying deprecated endpoints.
gotchaSerpApi accounts have daily usage limits. Exceeding these limits can result in `429 Too Many Requests` errors or your account running out of searches.
fix
Monitor your SerpApi usage on your dashboard. Implement exponential backoff or rate-limiting in your application to stay within API limits. Upgrade your SerpApi plan if higher throughput is consistently needed.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'google'
This error often occurs because developers confuse the `google-search-results` package with other libraries named 'google' or 'googlesearch', or they have not installed the correct package, or installed it in a different environment. The `google-search-results` library is part of the SerpApi ecosystem, and its main class is imported directly, not usually from a top-level 'google' module.
fix
Ensure you have installed the `google-search-results` package (or the recommended `serpapi` package) correctly using `pip install google-search-results` (or `pip install serpapi`). The import statement for `google-search-results` should be `from serpapi import GoogleSearch` or similar, depending on the specific usage, not `from google import search` or `from googlesearch import search` which belong to different, often unmaintained, libraries.
SerpApiError: You didn't supply an API Key.
This error indicates that the SerpApi client library was initialized or a search was attempted without a valid API key being provided, or the API key provided is incorrect/expired. SerpApi requires an API key for authentication to process search requests.
fix
Obtain a valid API key from your SerpApi dashboard (serpapi.com/manage-api-key) and pass it to the `GoogleSearch` constructor via the `api_key` parameter in the `params` dictionary, or set it as an environment variable (e.g., `SERPAPI_API_KEY`).

Example:
```python
from serpapi import GoogleSearch

params = {
    "api_key": "YOUR_API_KEY", # Replace with your actual API key
    "engine": "google",
    "q": "coffee",
    "location": "Austin, Texas, United States",
}

search = GoogleSearch(params)
results = search.get_dict()
```
HTTP 429: Too Many Requests
This error occurs when your SerpApi account has exceeded its allocated search quota or rate limit within a given timeframe. Google may also block requests if it detects automated scraping.
fix
Check your SerpApi account dashboard for your current search usage and rate limits. If you've run out of searches, you may need to upgrade your plan or wait for your quota to reset. If performing many requests, introduce delays between calls or consider using SerpApi's asynchronous or batch features if available in the `serpapi` library (the recommended successor).
{'error': 'Invalid API key. Your API key should be here: https://serpapi.com/manage-api-key'}
This is a specific error message returned directly from the SerpApi service, indicating that the provided API key is either missing, malformed, or not recognized as valid by SerpApi's servers. This is often due to typos or using an expired/incorrect key.
fix
Verify that the API key you are using is copied exactly from your SerpApi dashboard (https://serpapi.com/manage-api-key) and that it is active. Ensure there are no leading or trailing spaces or other hidden characters. Pass the correct key in your code.
Upgrade
Version history
2.4.2latest on PyPI · released Mar 10, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
google-search-results — pip install google-search-results · libregistry