MiniGroqqle is a minimalist web search component that allows Python developers to easily integrate web search capabilities into their applications. With just a few lines of code, you can perform Google searches and retrieve structured results.
-
Simple and lightweight
-
Easy to integrate
-
Customizable number of search results
-
Returns structured data (title, URL, and description) for each result
-
VIDEO: https://youtu.be/Y3srmpL8klY
MiniGroqqle now supports JSON output for easy integration with JSON-based applications. To get results in JSON format, simply set the json_output
parameter to True
when calling the search
method:
from minigroqqle import MiniGroqqle
searcher = MiniGroqqle(num_results=3)
results = searcher.search("Python programming", json_output=True)
print(results) # This will print a JSON string
When using JSON output, the results will be returned as a JSON-formatted string instead of a list of dictionaries. This makes it easy to parse and use the results in various applications or to send them over network protocols.
To install MiniGroqqle and its dependencies, run:
pip install requests beautifulsoup4
Then, download the minigroqqle.py
file and place it in your project directory.
Here's how to quickly get started with MiniGroqqle in your Python application:
- Import the MiniGroqqle class:
from minigroqqle import MiniGroqqle
- Create an instance of MiniGroqqle:
searcher = MiniGroqqle(num_results=5) # Specify the number of results you want
- Perform a search:
results = searcher.search("Python programming")
- Process the results:
for result in results:
print(f"Title: {result['title']}")
print(f"URL: {result['url']}")
print(f"Description: {result['description']}")
print("---")
That's it! You now have web search capabilities in your Python application.
Here's a complete example that you can run:
from minigroqqle import MiniGroqqle
searcher = MiniGroqqle(num_results=3)
results = searcher.search("Python programming")
for result in results:
print(f"Title: {result['title']}")
print(f"URL: {result['url']}")
print(f"Description: {result['description']}")
print("---")
MiniGroqqle now includes an API endpoint to perform searches and return results in JSON format. The API is built using Flask and provides a /search
endpoint that accepts a query parameter.
To run the API, first install the required dependencies:
pip install Flask
Then, create a file named api.py
with the following content:
from flask import Flask, request, jsonify
from minigroqqle import MiniGroqqle
app = Flask(__name__)
@app.route('/search', methods=['GET'])
def search():
query = request.args.get('query')
if not query:
return jsonify({"error": "Missing query parameter"}), 400
searcher = MiniGroqqle(num_results=5)
results = searcher.search(query, json_output=True)
return results
if __name__ == '__main__':
app.run(debug=True)
To start the API, run the following command:
python api.py
The API will be available at http://127.0.0.1:5000/search
.
To use the API, send a GET request to the /search
endpoint with a query
parameter. For example:
curl "http://127.0.0.1:5000/search?query=Python+programming"
The API will return the search results in JSON format.
We welcome contributions to MiniGroqqle! Please feel free to submit issues, fork the repository and send pull requests!
MiniGroqqle is released under the MIT License. Mention J. Gravelle in your code and documentation if you borrow any of this code. He's kinda full of himself...
This tool is for educational purposes only. Make sure to comply with the terms of service of the search engine you're querying. Be mindful of rate limiting and respect the usage policies of the services you're accessing.