Skip to main content

DuckPy

A simple Python module for searching on DuckDuckGo.

PyPI GitHub

Installation

Duckpy can be installed using pip with this command

pip install -U duckpy

Alternatively, you can install the most recent version from git

pip install -U git+https://github.com/AmanoTeam/duckpy

If you are using Debian or Ubuntu, you can install with this command (Currently only in Debian Unstable and Ubuntu 20.10+)

sudo apt install python3-duckpy

Usage

from duckpy import Client

client = Client()

results = client.search("Python Wikipedia")

# Prints first result title
print(results[0]["title"])

# Prints first result URL
print(results[0]["url"])

# Prints first result description
print(results[0]["description"])

We also provide an asynchronous version inside the AsyncClient class

import asyncio
from duckpy import AsyncClient

client = AsyncClient()

async def get_results():
  results = await client.search("Python Wikipedia")

  # Prints first result title
  print(results[0]["title"])

  # Prints first result URL
  print(results[0]["url"])

  # Prints first result description
  print(results[0]["description"])


loop = asyncio.get_event_loop()
loop.run_until_complete(get_results())

The result

Python (programming language) - Wikipedia
https://en.wikipedia.org/wiki/Python_(programming_language)
Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991...

Advanced usage

You can also set up proxies or set up custom User-Agent strings depending on your needs.

Setting up proxies

DuckDuckGo may temporarily block your request IP or return empty results, especially if you are using the library for scraping, bots and other stuff that generate many requests. This is not a duckpy issue and can be prevented using proxies.

You can pass a list with proxies in the Client object, then duckpy will use these proxies to make requests:

import duckpy

client = duckpy.Client(proxies=['http://123.45.67.89:80', 'https://98.76.54.32:443'])

If you pass more than one proxy, they will be randomly chosen every time you use the .search() method.

Setting up custom User-Agents

import duckpy

user_agents = [
  "Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0",
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"
]

client = duckpy.Client(default_user_agents=user_agents)

Again, if you pass more than one User-Agent, they will be randomly chosen every time you use the .search() method.

Disclaimer

We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with DuckDuckGo, or any of its subsidiaries or its affiliates. The official DuckDuckGo website can be found at https://duckduckgo.com.

Metadata

Release files for duckpy 3.0.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 duckpy 3.0.0
File Size Uploaded Provenance Actions
duckpy-3.0.0.tar.gz 3.8 kB Without provenance Details for duckpy-3.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 8.5 kB

Release files / duckpy-3.0.0.tar.gz

Download URL duckpy-3.0.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f8fcdcb2a4572bfc8573d5c85742faade35362e8ffabe43de87f8e0133f5b7e0
BLAKE2b-256 checksum
How to use checksums
ba713943ca47e0fd96a71241503957d37b5eaf6ddbfdac370c04ea6512fc248d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / duckpy-3.0.0-py3-none-any.whl

Download URL duckpy-3.0.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9778b94c92c7894ee7ff794a883c6af3b4fdb6a651ded62c209c9fabe5b908e4
BLAKE2b-256 checksum
How to use checksums
dfa9b93ae0f627b744ab3560e6da7720aeed9139c37a680abcdc37fdce41decb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for duckpy 3.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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