elm.web.search.google.PlaywrightGoogleCSELinkSearch

class PlaywrightGoogleCSELinkSearch(cse_url, **launch_kwargs)[source]

Bases: PlaywrightSearchEngineLinkSearch

Search for top links on a custom google search engine

Resources

https://programmablesearchengine.google.com/controlpanel/create

Parameters:
  • cse_url (str) – URL of the custom google programmable search engine.

  • **launch_kwargs – Keyword arguments to be passed to playwright.chromium.launch. For example, you can pass headless=False, slow_mo=50 for a visualization of the search.

Methods

results(*queries[, num_results])

Retrieve links for the first num_results of each query

Attributes

MAX_RESULTS_CONSIDERED_PER_PAGE

Number of results considered per search engine page

PAGE_LOAD_TIMEOUT

Default page load timeout value in milliseconds

PAGE_LOAD_TIMEOUT = 10000

Default page load timeout value in milliseconds

MAX_RESULTS_CONSIDERED_PER_PAGE = 10

Number of results considered per search engine page

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) – 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. By default, 10.

Returns:

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