refac
This commit is contained in:
1 parent
fd3368c0bf
commit
9adc0c442a
1 file changed
+6
-1
@@ -33,9 +33,14 @@ def search_duckduckgo(
|
|||||||
|
|
||||||
# Use the ddgs.text() method to perform the search
|
# Use the ddgs.text() method to perform the search
|
||||||
try:
|
try:
|
||||||
search_results = ddgs.text(query, safesearch='moderate', max_results=count, backend=backend)
|
kwargs = {"safesearch": "moderate", "max_results": count}
|
||||||
|
if backend and backend != "auto":
|
||||||
|
kwargs["backend"] = backend
|
||||||
|
results = ddgs.text(query, **kwargs)
|
||||||
|
search_results = results if results is not None else []
|
||||||
except RatelimitException as e:
|
except RatelimitException as e:
|
||||||
log.error(f'RatelimitException: {e}')
|
log.error(f'RatelimitException: {e}')
|
||||||
|
search_results = []
|
||||||
if filter_list:
|
if filter_list:
|
||||||
search_results = get_filtered_results(search_results, filter_list)
|
search_results = get_filtered_results(search_results, filter_list)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user