Skip to main content

Python library for fetching and parsing Google search results.

Project description

Google Search API Python Module

Overview

The Google Search API Python Module is a Python library that allows you to fetch and parse Google search results programmatically. It provides an easy-to-use interface to perform Google searches and retrieve search result data such as titles, URLs, snippets, and displayed links.

Installation

You can install the google-search-api module using pip:

pip install google-search-api

Usage

Basic Example

from google_search_api import GoogleSearchAPI

# Initialize GoogleSearchAPI object
google_search_api = GoogleSearchAPI()

# Perform a Google search
query = "Cyber Security"
num_results = 10
search_results = google_search_api.google_search(query, num_results)

# Print search results in JSON format
print(search_results)

Advanced Usage

Parameters

  • query (str): The search query to be performed.
  • num_results (int, optional): Number of search results to retrieve (default is 10).

Output

The google_search method returns a JSON string containing search results and metadata:

{
    "metadata": {
        "num_requested": 10,
        "total_items_fetched": 10,
        "runtime_seconds": 1.234
    },
    "results": [
        {
            "id": 1,
            "title": "Example Result Title",
            "link": "https://example.com",
            "snippet": "Example result snippet text.",
            "displayed_link": "example.com"
        },
        {
            "id": 2,
            "title": "Another Result Title",
            "link": "https://another-example.com",
            "snippet": "Another result snippet.",
            "displayed_link": "another-example.com"
        },
        ...
    ]
}

Notes

  • Duplicates: The module automatically removes duplicate URLs from the search results.
  • Snippet: Snippet text may not be available for all results depending on Google's HTML structure.

Contributing

Contributions to the google-search-api module are welcome! You can contribute by forking the repository, making changes, and submitting a pull request.

License

The google-search-api module is licensed under the MIT license.

Support

For any issues or questions related to the google-search-api module, please open an issue on GitHub.

Acknowledgments

  • The google-search-api module utilizes requests and beautifulsoup4 libraries for web scraping and parsing HTML.
  • This module was inspired by the Google Search API.

Authors

Changelog

  • v1.0.0 (2024-06-15)
    • Initial release of the google-search-api module.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_opensearch_api-1.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

google_opensearch_api-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file google_opensearch_api-1.0.0.tar.gz.

File metadata

  • Download URL: google_opensearch_api-1.0.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for google_opensearch_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2396b5c837173725aa9a5be2456e1a909e6c4a54bede3339b8dd4794f3db1033
MD5 1ebc2e078a3276a1b7ff44ab0ac2f520
BLAKE2b-256 22c30fb250d64d8292729a649dffa33380c8c816b18275a39806cc5d996e6110

See more details on using hashes here.

File details

Details for the file google_opensearch_api-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for google_opensearch_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 450aa2b75492c135435ae5a57ff6a57222f709fe4e8adc613a32eefa5dde8049
MD5 355d569a2675f61f126c7fdba940fd31
BLAKE2b-256 66b73990ea14dc2e921a5a40674afcbfb839100902c1028edde5bf1f21a75985

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page