Duckpy can be installed using pip with this command:
pip install -U duckpy
pip install -U git+https://github.com/AmanoTeam/duckpy
To use duckpy is easy, let's see some examples:
from duckpy import Client
client = Client()
results = client.search("Amano Team duckpy")
# 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:
import asyncio
from duckpy.aio import Client
client = Client()
async def get_results():
results = await client.search("Amano Team duckpy")
# 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:
GitHub - AmanoTeam/duckpy: 🦆 A simple Python module for ...
https://github.com/AmanoTeam/duckpy
🦆 A simple Python module for searching on DuckDuckGo - AmanoTeam/duckpy
You can also set up proxies and/or enable or disable random User-Agents depending on your needs.
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:https://123.45.67.89:80', 'https://98.76.54.32:443'])
If you pass more than one proxy, them will be randomly chosen every time you use the .search() method.