Lightweight web search adapters for Python. Queries multiple search engines and returns merged, structured results.
Logic is derived from SearXNG engine implementations.
Fetching pages is done by using Scrapling StealthySession.
| Engine | Key |
|---|---|
google |
|
| Bing | bing |
| DuckDuckGo | duckduckgo |
| Baidu | baidu |
(TODO, download the source currently)
pip install lightsearRequires Python 3.10+.
import lightsear
# Search all engines
results = lightsear.search("python web scraping")
# Search specific engines
results = lightsear.search("python web scraping", sources=["google", "duckduckgo"])
# With a proxy and custom timeout
results = lightsear.search(
"python web scraping",
sources=["google"],
timeout=30.0,
proxy="http://127.0.0.1:10808",
)
for r in results:
print(r.source, r.title, r.url)
print(r.content)Each result is a SearchResult dataclass:
@dataclass(frozen=True)
class SearchResult:
title: str
content: str # snippet / description
url: str
sources: str # engine name (splitted by comma)pip install -e ".[dev]"
pytestLogic adapted from SearXNG (AGPL-3.0-or-later).