elm.web.search.base.format_search_results

format_search_results(se_name, query, results, url_key, raw=False)[source]

Normalize structured search results into a consistent shape

Parameters:
  • se_name (str) – Name of the search engine that produced the results.

  • query (str) – The search query corresponding to the search results.

  • results (iterable of dict) – Iterable of search result records, where each record is a dict containing at least a key corresponding to url_key whose value is the URL of the search result.

  • url_key (str) – Key in each search result record that corresponds to the URL of the search result.

  • raw (bool, optional) – Option to return a list of dicts with attrs for each query instead of only a list of url strings. By default, False.

Returns:

list – List of URLs corresponding to the search results, or if raw=True, a list of dicts containing the URL and attrs for each search result.