Google Search automation using Playwright.
Provides functions for searching Google, extracting results, handling pagination, and supporting web, image, and news search types — all without any API key. Uses Playwright browser automation to navigate Google Search and extract structured data from the results pages.
Library functions take a Page as the first argument. The -main entry point provides a standalone CLI tool.
Usage (library): (search! page "clojure programming") (search! page "cats" {:type :images}) (next-page! page) (search-and-collect! page "clojure" {:max-pages 3})
Usage (CLI): spel search "clojure programming" spel search "cats" --images spel search "news topic" --news --json spel search "query" --page 2 --num 20
Google Search automation using Playwright.
Provides functions for searching Google, extracting results, handling
pagination, and supporting web, image, and news search types — all
without any API key. Uses Playwright browser automation to navigate
Google Search and extract structured data from the results pages.
Library functions take a Page as the first argument.
The -main entry point provides a standalone CLI tool.
Usage (library):
(search! page "clojure programming")
(search! page "cats" {:type :images})
(next-page! page)
(search-and-collect! page "clojure" {:max-pages 3})
Usage (CLI):
spel search "clojure programming"
spel search "cats" --images
spel search "news topic" --news --json
spel search "query" --page 2 --num 20(-main & args)CLI entry point for the search tool command.
Usage: spel search <query> [options]
See --help for all options.
CLI entry point for the search tool command. Usage: spel search <query> [options] See --help for all options.
(extract-image-results page)Extracts image search results from the current Google Images page. Uses JavaScript evaluation for resilient extraction.
Params:
page - Page instance.
Returns: Vector of maps with :title, :thumbnail-url, :source-url, :position.
Extracts image search results from the current Google Images page. Uses JavaScript evaluation for resilient extraction. Params: `page` - Page instance. Returns: Vector of maps with :title, :thumbnail-url, :source-url, :position.
(extract-news-results page)Extracts news search results from the current Google News results page. Uses JavaScript evaluation for resilient extraction.
Params:
page - Page instance.
Returns: Vector of maps with :title, :url, :source, :time, :snippet, :position.
Extracts news search results from the current Google News results page. Uses JavaScript evaluation for resilient extraction. Params: `page` - Page instance. Returns: Vector of maps with :title, :url, :source, :time, :snippet, :position.
(extract-people-also-ask page)Extracts 'People also ask' questions from the results page. Uses JavaScript evaluation for resilient extraction.
Params:
page - Page instance.
Returns: Vector of question strings.
Extracts 'People also ask' questions from the results page. Uses JavaScript evaluation for resilient extraction. Params: `page` - Page instance. Returns: Vector of question strings.
(extract-related-searches page)Extracts related search suggestions from the bottom of the results page. Uses JavaScript evaluation for resilient extraction.
Params:
page - Page instance.
Returns: Vector of suggestion strings.
Extracts related search suggestions from the bottom of the results page. Uses JavaScript evaluation for resilient extraction. Params: `page` - Page instance. Returns: Vector of suggestion strings.
(extract-result-stats page)Extracts the result statistics text (e.g. 'About 1,234 results').
Params:
page - Page instance.
Returns: String or nil.
Extracts the result statistics text (e.g. 'About 1,234 results'). Params: `page` - Page instance. Returns: String or nil.
(extract-web-results page)Extracts web search results from the current Google results page. Uses JavaScript evaluation for resilient extraction that survives Google DOM class changes.
Params:
page - Page instance.
Returns: Vector of maps with :title, :url, :snippet, :position.
Extracts web search results from the current Google results page. Uses JavaScript evaluation for resilient extraction that survives Google DOM class changes. Params: `page` - Page instance. Returns: Vector of maps with :title, :url, :snippet, :position.
(go-to-page! page query page-num)(go-to-page! page query page-num opts)Navigates directly to a specific page of search results using URL parameters.
Params:
page - Page instance.
query - String. The search query.
page-num - Long. 1-based page number.
opts - Map, optional. Same options as search-url.
Returns: Vector of result maps.
Navigates directly to a specific page of search results using URL parameters. Params: `page` - Page instance. `query` - String. The search query. `page-num` - Long. 1-based page number. `opts` - Map, optional. Same options as search-url. Returns: Vector of result maps.
(has-next-page? page)Returns true if there is a next page of results. Uses JavaScript evaluation for resilient detection.
Params:
page - Page instance.
Returns: Boolean.
Returns true if there is a next page of results. Uses JavaScript evaluation for resilient detection. Params: `page` - Page instance. Returns: Boolean.
(next-page! page)Navigates to the next page of results and waits for them to load. Uses the next-page URL from JavaScript evaluation instead of clicking, which is more reliable across Google DOM changes.
Returns the new page's web results, or nil if no next page.
Params:
page - Page instance.
Returns: Vector of result maps, or nil.
Navigates to the next page of results and waits for them to load. Uses the next-page URL from JavaScript evaluation instead of clicking, which is more reliable across Google DOM changes. Returns the new page's web results, or nil if no next page. Params: `page` - Page instance. Returns: Vector of result maps, or nil.
(search! page query)(search! page query opts)Navigates to Google Search and returns structured results.
Automatically warms up by visiting google.com first if the page is not already on a Google domain (required for stealth/bot bypass). Uses networkidle + wait-for-function for reliable result rendering.
Params:
page - Page instance.
query - String. The search query.
opts - Map, optional. Search options:
:type - Keyword. :web (default), :images, :news.
:page - Long. Page number (default 1).
:num - Long. Results per page (default 10).
:lang - String. Language code.
:safe - Keyword. :off, :medium, :high.
:time-range - Keyword. :day, :week, :month, :year.
Returns: Map with :query, :type, :stats, :results, :has-next?, :page, :people-also-ask, :related-searches.
Navigates to Google Search and returns structured results.
Automatically warms up by visiting google.com first if the page is
not already on a Google domain (required for stealth/bot bypass).
Uses networkidle + wait-for-function for reliable result rendering.
Params:
`page` - Page instance.
`query` - String. The search query.
`opts` - Map, optional. Search options:
:type - Keyword. :web (default), :images, :news.
:page - Long. Page number (default 1).
:num - Long. Results per page (default 10).
:lang - String. Language code.
:safe - Keyword. :off, :medium, :high.
:time-range - Keyword. :day, :week, :month, :year.
Returns:
Map with :query, :type, :stats, :results, :has-next?, :page,
:people-also-ask, :related-searches.(search-and-collect! page query)(search-and-collect! page query opts)Searches Google and collects results across multiple pages.
Params:
page - Page instance.
query - String. The search query.
opts - Map, optional. Same as search! opts, plus:
:max-pages - Long. Maximum number of pages to collect (default 1).
Returns: Map with :query, :type, :total-results (count), :pages (vector of page results).
Searches Google and collects results across multiple pages.
Params:
`page` - Page instance.
`query` - String. The search query.
`opts` - Map, optional. Same as search! opts, plus:
:max-pages - Long. Maximum number of pages to collect (default 1).
Returns:
Map with :query, :type, :total-results (count), :pages (vector of page results).(search-pages page query)(search-pages page query opts)Returns a lazy sequence of search result pages using clojure.core/iteration. Each element is a result map from search! (first page) or a map with :results, :page, :query, :type (subsequent pages).
Lazily fetches the next page only when consumed. Stops when Google reports no more pages.
Params:
page - Page instance.
query - String. The search query.
opts - Map, optional. Same as search! opts.
Returns: Lazy seq of page result maps. Use (mapcat :results ...) to get flat results.
Example: (->> (search-pages page "clojure") (take 3) (mapcat :results) (map :title))
Returns a lazy sequence of search result pages using clojure.core/iteration.
Each element is a result map from search! (first page) or a map with
:results, :page, :query, :type (subsequent pages).
Lazily fetches the next page only when consumed. Stops when Google
reports no more pages.
Params:
`page` - Page instance.
`query` - String. The search query.
`opts` - Map, optional. Same as search! opts.
Returns:
Lazy seq of page result maps. Use (mapcat :results ...) to get flat results.
Example:
(->> (search-pages page "clojure")
(take 3)
(mapcat :results)
(map :title))(search-url query)(search-url query opts)Builds a Google Search URL from a query string and options.
Params:
query - String. The search query.
opts - Map, optional. Search options:
:type - Keyword. :web (default), :images, :news.
:page - Long. 1-based page number (default 1).
:num - Long. Results per page, 10-100 (default 10).
:lang - String. 2-letter language code (e.g. "en").
:safe - Keyword. :off (default), :medium, :high.
:time-range - Keyword. :day, :week, :month, :year.
Returns: String. Fully-formed Google Search URL.
Builds a Google Search URL from a query string and options.
Params:
`query` - String. The search query.
`opts` - Map, optional. Search options:
:type - Keyword. :web (default), :images, :news.
:page - Long. 1-based page number (default 1).
:num - Long. Results per page, 10-100 (default 10).
:lang - String. 2-letter language code (e.g. "en").
:safe - Keyword. :off (default), :medium, :high.
:time-range - Keyword. :day, :week, :month, :year.
Returns:
String. Fully-formed Google Search URL.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |