A Python library for searching using DuckDuckGo.
Project description
DuckDuck Search Library
DuckDuck Search Library is a Python library that allows you to perform searches using DuckDuckGo. With a simple and clean API, you can quickly and easily retrieve relevant documents and links from the internet. The library supports features like rate limiting, domain filtering, and optional answer retrieval directly from DuckDuckGo.
Features
-
Easy Integration: Provides a simple and intuitive API for performing searches.
-
Rate Limiting: Built-in rate limiting helps to avoid making requests too frequently.
-
Domain Filtering: Restrict search results to a specific domain if required.
-
Optional Answer Retrieval: Optionally fetch direct answers from DuckDuckGo.
-
Flexible Configuration: Customizable parameters such as region, safe search settings, time limits, and more.
-
Python 3.7+ Compatible: Designed to work with modern versions of Python.
Installation
You can install the library via pip:
From PIP
pip install duckducksearch
From Source
pip install git+https://github.com/bes-dev/duckducksearch.git
Usage
from duckduck_search_lib import DuckDuckSearch
# Initialize the searcher with your desired configuration.
searcher = DuckDuckSearch(
top_k=10,
max_results=20,
region="wt-wt",
safesearch="moderate",
allowed_domain="", # Leave empty for no domain restriction
use_answers=False # Set to True if you want to retrieve direct answers from DuckDuckGo
)
# Define your search query and number of results to retrieve.
query = "What is Python?"
num_results = 5
# Perform the search.
results = searcher.search(query, num_results)
# Output the results.
print("Documents:")
for doc in results["documents"]:
print(f"Title: {doc.title}")
print(f"Content: {doc.content}")
print(f"Link: {doc.link}")
print("------------")
print("Links:")
for link in results["links"]:
print(link)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file duckducksearch-0.1.0.tar.gz.
File metadata
- Download URL: duckducksearch-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e08d68106670a9ca1121734b80981f45f52a65ab5037f5ff1f0f1c683111898d
|
|
| MD5 |
18a0876a857b35b42d3a08fd457280a9
|
|
| BLAKE2b-256 |
7a85de8366eded75220cf87a6eed037d3066b689f6542bea8bc9f4053ebbc29c
|
File details
Details for the file duckducksearch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: duckducksearch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcdf10de0d787ce3deb04e61c5aaa34b6f1565805fdd7884ea9b63a00194c42a
|
|
| MD5 |
373050606c6e509adf675080a5624e42
|
|
| BLAKE2b-256 |
1363344ea5bbd594bd9092ec2728cb05c96301ad7a27b620b801346fe06b3d2e
|