duckduckgo.py
1 from typing import List, Dict, Optional 2 3 4 def duckduckgo( 5 query: str, 6 region: Optional[str] = "wt-wt", 7 max_results: Optional[int] = 10, 8 ) -> List[Dict]: 9 """ 10 Make a query to DuckDuckGo search to receive a full search results. 11 12 Args: 13 query (str): The query to be passed to DuckDuckGo. 14 region (Optional[str]): The region to be used for the search in [country-language] convention, ex us-en, uk-en, ru-ru, etc... 15 max_results (Optional[int]): The maximum number of results to be returned. 16 """ 17 from ddgs import DDGS 18 19 ddg = DDGS() 20 return list(ddg.text(query, region=region, max_results=max_results))