代码拉取完成,页面将自动刷新
A Python library for querying the DuckDuckGo API.
Copyright (c) 2010 Michael Stephens <me@mikej.st> Copyright (c) 2012-2013 Michael Smith <crazedpsyc@gshellz.org>
Released under a 3-clause BSD license, see LICENSE for details.
Latest 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.
To install run
python setup.py install
>>> 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.
>>> 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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。