Returns a DuckDuckGo answer for the given string (e.g., math, spelling, ...)
(self, string, **kwargs)
| 1353 | return results |
| 1354 | |
| 1355 | def answer(self, string, **kwargs): |
| 1356 | """ Returns a DuckDuckGo answer for the given string (e.g., math, spelling, ...) |
| 1357 | """ |
| 1358 | url = URL(DUCKDUCKGO, method=GET, query={ |
| 1359 | "q": string, |
| 1360 | "o": "json" |
| 1361 | }) |
| 1362 | kwargs.setdefault("cached", False) |
| 1363 | kwargs.setdefault("unicode", True) |
| 1364 | kwargs.setdefault("throttle", self.throttle) |
| 1365 | data = url.download(**kwargs) |
| 1366 | data = json.loads(data) |
| 1367 | data = data.get(kwargs.get("field", "Answer")) |
| 1368 | return u(data) |
| 1369 | |
| 1370 | def spelling(self, string): |
| 1371 | """ Returns a list of spelling suggestions for the given string. |
no test coverage detected