Skip to content

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.

Notifications You must be signed in to change notification settings

jgravelle/MiniGroqqle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiniGroqqle: Lightweight Web Search for Python

image

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.

Features

  • 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

JSON Output

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.

Installation

To install MiniGroqqle and its dependencies, run:

pip install requests beautifulsoup4

Then, download the minigroqqle.py file and place it in your project directory.

QuickStart

Here's how to quickly get started with MiniGroqqle in your Python application:

  1. Import the MiniGroqqle class:
from minigroqqle import MiniGroqqle
  1. Create an instance of MiniGroqqle:
searcher = MiniGroqqle(num_results=5)  # Specify the number of results you want
  1. Perform a search:
results = searcher.search("Python programming")
  1. 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.

Example

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("---")

API Usage

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.

Running the API

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.

Using the API

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.

Contributing

We welcome contributions to MiniGroqqle! Please feel free to submit issues, fork the repository and send pull requests!

License

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...

Disclaimer

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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages