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

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

Credits

This library was developed with extensive assistance from the Jules AI coding assistant.

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.1.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.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mini_search_engine-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 bdf0f37edad5fb79f1b722e0215c793fe9597ffbf1349f2d04edebe76a827596
MD5 b094df35169aa2c5f5ffb09aa5c383a6
BLAKE2b-256 226451275b1e9c9fd246a33fd841a20013f45efa6ef254dd920d02572798a84e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mini_search_engine-1.0.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mini_search_engine-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e92a5b0b2e4f155a1b8bb827b5d7fc8cb8e18db181bd133ad881d105d354e89e
MD5 f439728fd971f42d471a404d9bdace95
BLAKE2b-256 c0b26a6c40c461c00f4e383bba57868c53227c8b4c4607c1818d65a56b16e18c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mini_search_engine-1.0.1-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