Skip to main content

A simple module for searching on DuckDuckGo

Project description

DuckPy
A simple Python module that searches on DuckDuckGo.

Installation:

Duckpy can be installed using pip from PyPI or from GitHub

via PyPI using pip:

pip install -U duckpy

via GitHub using pip+git:

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

Usage:

To use duckpy is easy, let's see some examples:

First example (normal version):

import duckpy

client = duckpy.Client()

search = client.search("Amano Team duckpy")

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

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

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

The result:

GitHub - AmanoTeam/duckpy: A simple Python module that ...
https://github.com/AmanoTeam/duckpy
A simple Python module that searches on DuckDuckGo - AmanoTeam/duckpy

First example (asyncio version):

import asyncio
import duckpy.aio

client = duckpy.aio.Client()

async def get_results():
  search = await client.search("Amano Team duckpy")

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

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

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


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

The result:

GitHub - AmanoTeam/duckpy: A simple Python module that ...
https://github.com/AmanoTeam/duckpy
A simple Python module that searches on DuckDuckGo - AmanoTeam/duckpy

Advanced usage:

You can also set up proxies and/or enable or disable random User-Agents depending on your needs.

Setting up proxies:

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

Example:

import duckpy

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

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

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

duckpy-2.0.0.tar.gz (2.7 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page