googlesearch is a Python library for scraping the Google search engine. It uses `requests` and `BeautifulSoup4` to parse Google's search results. The library is actively maintained with releases addressing changes in Google's search page structure. The current version is 1.3.0, released January 21, 2025.
pip install googlesearch-pythonVerified import paths — ran on the pinned version, not inferred.
Performs a Google search for a given query and prints the top 5 unique URLs. It demonstrates how to use the `pause` parameter to prevent IP blocking and includes a commented section for retrieving `advanced` search results with titles and descriptions.
Upgrade to the latest version (`1.3.0` or newer). Version `1.3.0` specifically addressed issues by updating the parsing logic and using a 'Lynx' user-agent to bypass Google's changes. Regular updates are recommended as Google's layout can change without notice.
Use the `pause` parameter in the `search()` function to introduce delays between requests (e.g., `search(query, pause=2)` for a 2-second delay). For high-volume or commercial scraping, consider rotating proxies or Google's official Custom Search API.
Ensure you install the correct package using `pip install googlesearch-python` and import it with `from googlesearch import search`. Verify the installed package using `pip show googlesearch-python`.
To retrieve more detailed information (title, URL, description), pass `advanced=True` to the `search()` function. This will yield `SearchResult` objects with the desired attributes.
Ensure you have installed the correct package using `pip install googlesearch-python`. If you previously installed `google` or `google-search`, uninstall them first and then install `googlesearch-python`. Also, verify you are running your script in the Python environment where the library was installed.
Implement delays between your search queries using the `pause` parameter in the `search()` function (e.g., `pause=2` for a 2-second delay). For extensive scraping, consider using rotating proxies and user-agents, or exploring official Google APIs if your use case allows.
Verify that `googlesearch-python` is correctly installed. If issues persist, try uninstalling potentially conflicting packages like `google` or `google-search` (`pip uninstall google google-search`) and then reinstall `googlesearch-python`. Also, check your project directory for any files named `google.py`.
Ensure that `googlesearch-python` is the only relevant Google search library installed and that it is up to date (`pip install --upgrade googlesearch-python`). This error often points to a conflict with the `google` package which might have been installed instead of `googlesearch-python`.