fix duckduckgo.py (#1497)

### What problem does this PR solve?



### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
H 2024-07-12 19:43:18 +08:00 committed by GitHub
parent eecec7b119
commit 38a90c32b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -46,12 +46,12 @@ class DuckDuckGo(ComponentBase, ABC):
if not ans:
return DuckDuckGo.be_output(self._param.no)
if self.channel == "text":
if self._param.channel == "text":
with DDGS() as ddgs:
# {'title': '', 'href': '', 'body': ''}
duck_res = [{"content": '<a href="' + i["href"] + '">' + i["title"] + '</a> ' + i["body"]} for i in
ddgs.text(ans, max_results=self._param.top_n)]
elif self.channel == "news":
elif self._param.channel == "news":
with DDGS() as ddgs:
# {'date': '', 'title': '', 'body': '', 'url': '', 'image': '', 'source': ''}
duck_res = [{"content": '<a href="' + i["url"] + '">' + i["title"] + '</a> ' + i["body"]} for i in