Skip to main content

A simple search engine library scraping Google and DuckDuckGo.

Project description

Mini Search Engine

A flexible Python library that scrapes Google and DuckDuckGo for search results. It supports extensive search features including pagination, safe search, and time filtering.

Features

  • Multi-Engine Support: Search via Google or DuckDuckGo.
  • Smart Fallback: Automatically tries the next available engine if the primary one is blocked (e.g., falls back to DuckDuckGo if Google blocks).
  • Pagination: Retrieve as many results as you need.
  • Safe Search: Control safe search strictness (strict, moderate, off).
  • Time Filtering: Filter results by day, week, month, or year.
  • No API Key Needed: Uses direct web scraping.

Installation

You can install the package directly from PyPI:

pip install mini-search-engine

Or install locally from source:

git clone https://github.com/yourusername/mini-search-engine.git
cd mini-search-engine
pip install .

Usage

from mini_search_engine import SearchEngine
import logging

# Optional: Enable logging to see what's happening under the hood
logging.basicConfig(level=logging.INFO)

engine = SearchEngine()

# Simple Search
results = engine.search("python programming")
for res in results:
    print(res['title'], res['link'])

# Advanced Search with Filters
results = engine.search(
    "latest python news",
    engine="auto",       # Try Google, then DDG
    limit=20,            # Get 20 results (handles pagination automatically)
    safe="strict",       # Strict safe search
    time_range="w"       # Past week
)

print(f"\nFound {len(results)} results:")
for i, res in enumerate(results):
    print(f"#{i+1} [{res['source']}] {res['title']}")
    print(f"Link: {res['link']}")
    print(f"Snippet: {res['snippet']}")
    print("-" * 30)

API Reference

search(query, engine="auto", limit=10, safe="moderate", time_range=None)

  • query (str): The search query.
  • engine (str): 'google', 'ddg', or 'auto'. Defaults to 'auto'.
  • limit (int): Number of results to return. Defaults to 10.
  • safe (str): Safe search level: 'strict', 'moderate', 'off'. Defaults to 'moderate'.
  • time_range (str): 'd' (day), 'w' (week), 'm' (month), 'y' (year). Defaults to None (any time).

License

MIT License

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

mini_search_engine-1.0.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mini_search_engine-1.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mini_search_engine-1.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mini_search_engine-1.0.0.tar.gz
Algorithm Hash digest
SHA256 47412f5688da4f924b6e1312751cfcbd3c3e43a8ad47a539752770840927c821
MD5 be4d82a0a0642fe9306736b172d71aae
BLAKE2b-256 82cf9b8d95062500bcb755b704ababcd3fa98628b199e71976d89cc05086360d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mini_search_engine-1.0.0.tar.gz:

Publisher: python-publish.yml on Shrisal/Web-Search-Python-Library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for mini_search_engine-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d1897c6aa8ae6edd858890f2e842260382a032a2f7f0d4263bfaf3457d63117
MD5 876ad7930ae50000cb4088c82f8ef64c
BLAKE2b-256 9a31eddddecac51aecc9281b2c0a80f48280e702ab7ed064761a6942f7a93d24

See more details on using hashes here.

Provenance

The following attestation bundles were made for mini_search_engine-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on Shrisal/Web-Search-Python-Library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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