Google Open 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-opensearch-api module using pip:
pip install google-opensearch-api
Usage
Basic Example
from google_search_api.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).
CLI Usage
You can use the google-opensearch command line tool to perform Google searches:
google-search "cyber security" --num_results 5
Docker Container Usage
You can use the google-opensearch-api Docker container to perform Google searches:
docker run -it --rm google-opensearch-api "cyber security" --num_results 5
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
- CuriousTinker - https://github.com/CuriousTinker
Changelog
- v1.0.0 (2024-06-15)
- Initial release of the google-search-api module.
Metadata
Release files for google-opensearch-api 1.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| google_opensearch_api-1.0.13.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| google_opensearch_api-1.0.13-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / google_opensearch_api-1.0.13.tar.gz
| Download URL | google_opensearch_api-1.0.13.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be1eb11dd35e93d3f73470f4195d68a4e550d42b70e0c87089c607c304e86228
|
|
BLAKE2b-256 checksum How to use checksums |
6311974a4d938114865e87a87b58ad70a13a596ff1f186dead328134e30f0359
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|
Release files / google_opensearch_api-1.0.13-py3-none-any.whl
| Download URL | google_opensearch_api-1.0.13-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f0b2ebf2a872c38731d57c9d9cb5fbd9a24c569562427c287f9a175815b5e60
|
|
BLAKE2b-256 checksum How to use checksums |
65cb3f7211e4c7ea653bed9bf2d02de78e5962f9937b8f80cd0648a3a4fc0cff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.19
|