Browse files

add option to ignore ZCI urls in get_zci

  • Loading branch information...
1 parent 8cc7b1b commit d7646b9055144bbd422648c5fdc139eaeca06625 @crazedpsyc committed Sep 30, 2012
Showing with 4 additions and 4 deletions.
  1. +1 −1 README.rst
  2. +3 −3
@@ -58,7 +58,7 @@ Usage
>>> 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:
+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. (
>>> print ddg.get_zci('foo fighters site')
@@ -3,7 +3,7 @@
import json as j
import sys
-__version__ = 0.21
+__version__ = 0.24
def query(query, useragent='python-duckduckgo '+str(__version__), safesearch=True, html=False, meanings=True, **kwargs):
@@ -127,7 +127,7 @@ def __init__(self, json):
self.source = json.get('DefinitionSource')
-def get_zci(q, web_fallback=True, priority=['answer', 'abstract', 'related.0', 'definition'], **kwargs):
+def get_zci(q, web_fallback=True, priority=['answer', 'abstract', 'related.0', 'definition'], urls=True, **kwargs):
'''A helper method to get a single (and hopefully the best) ZCI result.
priority=list can be used to set the order in which fields will be checked for answers.
Use web_fallback=True to fall back to grabbing the first web result.
@@ -148,7 +148,7 @@ def get_zci(q, web_fallback=True, priority=['answer', 'abstract', 'related.0', '
if not result: continue
if result.text: response = result.text
- if result.text and hasattr(result,'url'):
+ if result.text and hasattr(result,'url') and urls:
if result.url: response += ' (%s)' % result.url
if response: break

0 comments on commit d7646b9

Please sign in to comment.