Skip to main content

www.duckduckgo.com zero-click api for your command-line

Project description

Duck Duck Go zero-click api for your command-line

Install

pip install ddg

or from the source:

python setup.py install

Usage

www.duckduckgo.com zero-click api for your command-line [-h] [-b] [-d] [-j] [-l] [-s] [-u] [query [query …]]

positional arguments:
query the search query
optional arguments:
-h, --help show this help message and exit
-b, --bang prefix query with ! and launch the redirect url
-d, --define attempt to return the definition
-j, --json returns the raw json output
-l, --lucky launch the first url found
-s, --search launch a search on www.duckduckgo.com
-u, --url return the url of the result found

Examples

Call ddg from your command line to access the Duck Duck Go Zero-Click Info API

$ ddg my ip
Your IP address is <ip> in <location>
$ ddg schnauzer
A schnauzer is a dog breed that originated in Germany in the 15th and 16th centuries.

Use the -u flag to return the url of the answer source.

$ ddg schnauzer -u
https://en.wikipedia.org/wiki/Schnauzer

You can get a definition using the -d flag

$ ddg catfish -d
catfish definition: any of an order (Siluriformes) of chiefly
freshwater stout-bodied scaleless bony fishes having long tactile barbels.

Combinining flags behaves as expected

$ ddg catfish -d -u
http://www.merriam-webster.com/dictionary/catfish

You can use the -b flag to launch a !Bang redirect in your browser

Launch a query on Wolfram Alpha

$ ddg wa integral of sin x / x from negative inf to inf -b

Launch a search on Stack Overflow

$ ddg so [c++11] lambda return values -b

Launch a search on Python for the webbrowser module

$ ddg py webbrowser -b

Feeling lucky? Launch the Python webbrowser documentation directly with -l

$ ddg python webbrowser -l

You can launch a search on Duck Duck Go with the -s flag

$ ddg Lord of the Rings -s

ddg plays nice with all the unix-like utilities you know and love

$ echo "shark" | ddg -d -l

Use -j to output the json response from the API

$ ddg simpsons characters -j >> file.txt

Attempt to print definition urls for all file and folder names in your current directory

$ ls | ddg -du

Thanks

The duckduckgo module is a modification from http://github.com/crazedpsyc/python-duckduckgo.
Original duckduckgo module source from http://github.com/mikejs/python-duckduckgo (outdated)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ddg, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size ddg-0.2.0.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page