Skip to main content

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)

Metadata

Release files for duckducksearch 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for duckducksearch 0.1.0
File Size Uploaded
duckducksearch-0.1.0.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for duckducksearch 0.1.0
File Interpreter ABI Platform
duckducksearch-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / duckducksearch-0.1.0.tar.gz

Download URL duckducksearch-0.1.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e08d68106670a9ca1121734b80981f45f52a65ab5037f5ff1f0f1c683111898d
BLAKE2b-256 checksum
How to use checksums
7a85de8366eded75220cf87a6eed037d3066b689f6542bea8bc9f4053ebbc29c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / duckducksearch-0.1.0-py3-none-any.whl

Download URL duckducksearch-0.1.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcdf10de0d787ce3deb04e61c5aaa34b6f1565805fdd7884ea9b63a00194c42a
BLAKE2b-256 checksum
How to use checksums
1363344ea5bbd594bd9092ec2728cb05c96301ad7a27b620b801346fe06b3d2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page