Skip to content

Commit d7646b9

Browse files
committed
add option to ignore ZCI urls in get_zci
1 parent 8cc7b1b commit d7646b9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Usage
5858
>>> print duckduckgo.query('how to spell test', html=True).answer.text
5959
<b>Test</b> appears to be spelled right!<br/><i>Suggestions: </i>test, testy, teat, tests, rest, yest.
6060

61-
# The easiest method of quickly grabbing the best (hopefully) API result is to use duckduckgo.get_zci:
61+
The easiest method of quickly grabbing the best (hopefully) API result is to use duckduckgo.get_zci::
6262
>>> print duckduckgo.get_zci('foo')
6363
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)
6464
>>> print ddg.get_zci('foo fighters site')

duckduckgo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json as j
44
import sys
55

6-
__version__ = 0.21
6+
__version__ = 0.24
77

88

99
def query(query, useragent='python-duckduckgo '+str(__version__), safesearch=True, html=False, meanings=True, **kwargs):
@@ -127,7 +127,7 @@ def __init__(self, json):
127127
self.source = json.get('DefinitionSource')
128128

129129

130-
def get_zci(q, web_fallback=True, priority=['answer', 'abstract', 'related.0', 'definition'], **kwargs):
130+
def get_zci(q, web_fallback=True, priority=['answer', 'abstract', 'related.0', 'definition'], urls=True, **kwargs):
131131
'''A helper method to get a single (and hopefully the best) ZCI result.
132132
priority=list can be used to set the order in which fields will be checked for answers.
133133
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', '
148148
if not result: continue
149149

150150
if result.text: response = result.text
151-
if result.text and hasattr(result,'url'):
151+
if result.text and hasattr(result,'url') and urls:
152152
if result.url: response += ' (%s)' % result.url
153153
if response: break
154154

0 commit comments

Comments
 (0)