Skip to main content

Library for querying the DuckDuckGo API

Project description

A Python library for querying the DuckDuckGo API.

Copyright Michael Stephens <me@mikej.st>, released under a BSD-style license.

Source: http://github.com/crazedpsyc/python-duckduckgo Original source: http://github.com/mikejs/python-duckduckgo (outdated)

This version has been forked from the original to handle some new features of the API, and switch from XML to JSON.

Installation

To install run

python setup.py install

Usage

>>> import duckduckgo
>>> r = duckduckgo.query('DuckDuckGo')
>>> r.type
u'answer'
>>> r.results[0].text
u'Official site'
>>> r.results[0].url
u'http://duckduckgo.com/'
>>> r.abstract.url
u'http://en.wikipedia.org/wiki/Duck_Duck_Go'
>>> r.abstract.source
u'Wikipedia'
>>> r = duckduckgo.query('Python')
>>> r.type
u'disambiguation'
>>> r.related[1].text
u'Python (programming language), a computer programming language'
>>> r.related[1].url
u'http://duckduckgo.com/Python_(programming_language)'
>>> r.related[7].topics[0].text # weird, but this is how the DDG API is currently organized
u'Armstrong Siddeley Python, an early turboprop engine'
>>> r = duckduckgo.query('1 + 1')
>>> r.type
u'nothing'
>>> r.answer.text
u'1 + 1 = 2'
>>> r.answer.type
u'calc'
>>> print duckduckgo.query('19301', kad='es_ES').answer.text
19301 es un código postal de Paoli, PA
>>> print duckduckgo.query('how to spell test', html=True).answer.text
<b>Test</b> appears to be spelled right!<br/><i>Suggestions: </i>test, testy, teat, tests, rest, yest.
The easiest method of quickly grabbing the best (hopefully) API result is to use duckduckgo.get_zci::
>>> print duckduckgo.get_zci('foo')
The terms foobar /ˈfʊːbɑːr/, fubar, or foo, bar, baz and qux are sometimes used as placeholder names in computer programming or computer-related documentation. (https://en.wikipedia.org/wiki/Foobar)
>>> print ddg.get_zci('foo fighters site')
http://www.foofighters.com/us/home
Special keyword args for query():
  • useragent - string, The useragent used to make API calls. This is somewhat irrelevant, as they are not logged or used on DuckDuckGo, but it is retained for backwards compatibility.

  • safesearch - boolean, enable or disable safesearch.

  • html - boolean, Allow HTML in responses?

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

duckduckgo3-0.242.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

duckduckgo3-0.242-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file duckduckgo3-0.242.tar.gz.

File metadata

  • Download URL: duckduckgo3-0.242.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.15+

File hashes

Hashes for duckduckgo3-0.242.tar.gz
Algorithm Hash digest
SHA256 4d41fa5eb9d2ee7fc904ffea5ae1bf8ec35d89badb0cd9635f576ff7eb0065c6
MD5 0666889c11ebf78ac7ac0c2e05db533c
BLAKE2b-256 34b040033e5487d0838846eb515b3fb0f22b65b32fbd00b481c22ce7a327b16e

See more details on using hashes here.

File details

Details for the file duckduckgo3-0.242-py3-none-any.whl.

File metadata

  • Download URL: duckduckgo3-0.242-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.15+

File hashes

Hashes for duckduckgo3-0.242-py3-none-any.whl
Algorithm Hash digest
SHA256 0635e80c477852290ddb710aaa2fcc5db1634bfac4dc22427eed8af64270871f
MD5 124ec50f50307490270ccc9c3037879b
BLAKE2b-256 590e5519075837ea994c84ceff18268e23058fed2fc5d358e50db2c6a688e2ad

See more details on using hashes here.

Supported by

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