elm.web.search.duckduckgo.APIDuckDuckGoSearch

class APIDuckDuckGoSearch(region='us-en', timeout=10, verify=False, sleep_min_seconds=10, sleep_max_seconds=20)[source]

Bases: SearchEngineLinkSearch

Search the web for links using the DuckDuckGo API

Parameters:
  • region (str, optional) – DDG search region param. By default, "us-en".

  • timeout (int, optional) – Timeout for HTTP requests, in seconds. By default, 10.

  • verify (bool, optional) – Apply SSL verification when making the request. By default, False.

  • sleep_min_seconds (int, optional) – Minimum number of seconds to sleep between queries. We recommend not setting this below 5 seconds to avoid rate limiting errors thrown by DuckDuckGo. By default, 10.

  • sleep_max_seconds (int, optional) – Maximum number of seconds to sleep between queries. By default, 20.

Methods

results(*queries[, num_results])

Retrieve links for the first num_results of each query

async results(*queries, num_results=10)

Retrieve links for the first num_results of each query

This function executes a search for each input query and returns a list of links corresponding to the top num_results.

Parameters:
  • *queries (str) – One or more queries to search for.

  • num_results (int, optional) – Maximum number of top results to retrieve for each query. Note that this value can never exceed the number of results per page (typically 10). If you pass in a larger value, it will be reduced to the number of results per page. There is also no guarantee that the search query will return this many results - the actual number of results returned is determined by the number of results on a page (excluding ads). You can, however, use this input to limit the number of results returned. By default, 10.

Returns:

list – List equal to the length of the input queries, where each entry is another list containing no more than num_results links.