elm.web.google_search.PlaywrightGoogleLinkSearch
- class PlaywrightGoogleLinkSearch(**launch_kwargs)[source]
Bases:
object
Search for top results on google and return their links
- Purpose:
Search Google using Playwright engine.
- Responsibilities:
Launch browser using Playwright and navigate to Google.
Submit a query to Google Search.
Get list of resulting URLs.
- Key Relationships:
Relies on Playwright for web access.
- Parameters:
**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
Number of results displayed per Google page.
- EXPECTED_RESULTS_PER_PAGE = 10
Number of results displayed per Google page.
- async results(*queries, num_results=10)[source]
Retrieve links for the first num_results of each query.
This function executes a google search for each input query and returns a list of links corresponding to the top num_results.
- Parameters:
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.