Vexaloom Labs

Use Google Search Results Scraper: Organic & SERP Boxes with Python

Search Google and get organic results plus AI Overview, knowledge panel, People Also Ask, related searches, local pack, top stories and ads for each query, across 48 countries with language and date filters.

1. Choose the data you need

Review the published README for supported collection modes, examples, and limits. The recipe below uses the current published input definition.

2. Prepare a source-based input

This JSON contains published prefills and required-field defaults. Review every value for your task before running it; it is not a promise of successful collection.

{
  "countryCode": "us",
  "csvFriendlyOutput": false,
  "dateFrom": "",
  "dateTo": "",
  "exactPhrase": false,
  "excludeTerms": "",
  "fileType": "",
  "includeAiOverview": false,
  "includeDestinationUrl": false,
  "includeExtraBoxes": false,
  "intext": "",
  "intitle": "",
  "inurl": "",
  "languageCode": "en",
  "maxPagesPerQuery": 1,
  "maxResults": 3,
  "queries": [
    "Hotels in NYC"
  ],
  "restrictResultsCountry": "",
  "restrictResultsLanguage": "",
  "safeSearch": "",
  "searchType": "web",
  "site": "",
  "timePeriod": "",
  "uule": ""
}

Download input.example.json and save your reviewed copy as input.json.

FieldTypeRequiredDescription
queriesarrayrequiredGoogle search queries. Each is searched separately; blank entries are dropped with a warning.
searchTypestringoptionalWhich Google surface to scrape: web organic results, news cards, images, or videos.
maxResultsintegeroptionalMaximum items to return per query. Web results stop at Google's own ceiling of roughly 70-100; images return 50-100 per query and news/videos paginate in pages of 10.
countryCodestringoptionalCountry for the Google domain and searcher-location (gl) signal. Leave empty for US (google.com); if Precise Location is set and this is empty, the country is derived from it.
restrictResultsCountrystringoptionalOnly return pages whose content originates from this country (Google's cr parameter), independent of Country/gl. Leave empty for no restriction.
languageCodestringoptionalLanguage of Google's own interface, e.g. en, de, fr, es. This does not restrict the language of the matched pages.
restrictResultsLanguagestringoptionalOnly return pages written in this language, e.g. en or en,fr for either. Leave empty for no restriction.
maxPagesPerQueryintegeroptionalResult pages to crawl per query for web, news and videos. Images are a single page. Web results stop at Google's own ceiling of roughly 7-10 pages.
timePeriodstringoptionalFilter results by relative time. Leave empty for any time.
safeSearchstringoptionalFilter explicit content (safe=). Leave empty for Google's default.
includeAiOverviewbooleanoptionalOpt-in browser-rendered AI Overview for web searches. Slower and not guaranteed: Google may not show one, and the text is best-effort. Only applies to web search.
includeDestinationUrlbooleanoptionalAdd a destinationUrl field with the real destination behind Google's redirect link. Adds one lookup per organic result. Only applies to web search.
csvFriendlyOutputbooleanoptionalFor web search, output one organic/paid result per row instead of one SERP page per row. Other SERP features are not included in this layout.
includeExtraBoxesbooleanoptionalFor web search, also extract weather, time zone, currency/unit converter, stock, jobs, videos, shopping and dictionary boxes when present.
uulestringoptionalOptional Google-encoded location for city-level targeting. Best-effort: country targeting is reliable, city precision is not guaranteed. Leave empty to use Country only.
dateFromstringoptionalOnly include results published on or after this date (YYYY-MM-DD). Must be used with Date to.
dateTostringoptionalOnly include results published on or before this date (YYYY-MM-DD). Must be used with Date from.
exactPhrasebooleanoptionalWrap each query in quotes so Google matches it as an exact phrase.
sitestringoptionalRestrict results to this domain, e.g. nike.com. Every organic result is checked against it; off-domain results Google slips in are dropped.
intitlestringoptionalRestrict results to pages containing this word in the title. Sent to Google as-is.
intextstringoptionalRestrict results to pages containing this word in the body text. Sent to Google as-is.
inurlstringoptionalRestrict results to pages containing this word in the URL. Sent to Google as-is.
fileTypestringoptionalRestrict results to a file type, e.g. pdf, doc, xls. Sent to Google as-is.
excludeTermsstringoptionalWords to exclude, comma- or space-separated, e.g. jaguar, cats.

3. Start an Actor run

Set APIFY_TOKEN in your environment. Python 3.10 or newer is sufficient; this recipe uses no third-party packages.

Execution may incur charges. Review current pricing on Apify. The request asks for a 120-second timeout and a charge limit; these settings are subject to Apify’s pricing and do not guarantee an all-inclusive spending cap.

import json
import os
import urllib.request

# Save the schema-derived example as input.json; review and edit it first.
with open("input.json", encoding="utf-8") as stream:
    actor_input = json.load(stream)

token = os.environ["APIFY_TOKEN"]
request = urllib.request.Request(
    "https://api.apify.com/v2/acts/PlIxbe9L7Qn7c76R7/runs?timeout=120&maxTotalChargeUsd=0.50",
    data=json.dumps(actor_input).encode("utf-8"),
    headers={"Authorization": "Bearer " + token, "Content-Type": "application/json"},
    method="POST",
)
# This starts a potentially billable run. Do not automatically retry this POST.
with urllib.request.urlopen(request, timeout=40) as response:
    run = json.load(response)["data"]
print("Run ID:", run["id"])
print("Status:", run["status"])
# Inspect and download results in Apify Console once the run succeeds.

4. Inspect the actual results

Open the run in Apify Console and wait for a successful completion. Use the published output schema to locate results and the dataset schema to understand declared views. Missing or optional record fields must not be treated as guaranteed values.

One record per search query/page with web organic results, news cards, images, videos, AI Overview, People Also Ask, local pack, related queries and paid results.

Questions before you run

Which inputs are required?

The published required fields are queries

What does this guide verify?

The fields, prefills, and schema links are rendered from the published build. This is a usage recipe, not a paid live extraction test. Source availability and collection results can vary.

What if the run request times out?

Check Apify Console before retrying. The first request may already have created a run. Do not automatically repeat a run-creation POST.

Generated from source build NG6Y2OAdaEEnxj85d and its README and schemas. Source changes regenerate this guide; no third-party editorial claims are inferred.