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.
| Field | Type | Required | Description |
|---|---|---|---|
queries | array | required | Google search queries. Each is searched separately; blank entries are dropped with a warning. |
searchType | string | optional | Which Google surface to scrape: web organic results, news cards, images, or videos. |
maxResults | integer | optional | Maximum 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. |
countryCode | string | optional | Country 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. |
restrictResultsCountry | string | optional | Only return pages whose content originates from this country (Google's cr parameter), independent of Country/gl. Leave empty for no restriction. |
languageCode | string | optional | Language of Google's own interface, e.g. en, de, fr, es. This does not restrict the language of the matched pages. |
restrictResultsLanguage | string | optional | Only return pages written in this language, e.g. en or en,fr for either. Leave empty for no restriction. |
maxPagesPerQuery | integer | optional | Result 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. |
timePeriod | string | optional | Filter results by relative time. Leave empty for any time. |
safeSearch | string | optional | Filter explicit content (safe=). Leave empty for Google's default. |
includeAiOverview | boolean | optional | Opt-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. |
includeDestinationUrl | boolean | optional | Add a destinationUrl field with the real destination behind Google's redirect link. Adds one lookup per organic result. Only applies to web search. |
csvFriendlyOutput | boolean | optional | For 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. |
includeExtraBoxes | boolean | optional | For web search, also extract weather, time zone, currency/unit converter, stock, jobs, videos, shopping and dictionary boxes when present. |
uule | string | optional | Optional Google-encoded location for city-level targeting. Best-effort: country targeting is reliable, city precision is not guaranteed. Leave empty to use Country only. |
dateFrom | string | optional | Only include results published on or after this date (YYYY-MM-DD). Must be used with Date to. |
dateTo | string | optional | Only include results published on or before this date (YYYY-MM-DD). Must be used with Date from. |
exactPhrase | boolean | optional | Wrap each query in quotes so Google matches it as an exact phrase. |
site | string | optional | Restrict results to this domain, e.g. nike.com. Every organic result is checked against it; off-domain results Google slips in are dropped. |
intitle | string | optional | Restrict results to pages containing this word in the title. Sent to Google as-is. |
intext | string | optional | Restrict results to pages containing this word in the body text. Sent to Google as-is. |
inurl | string | optional | Restrict results to pages containing this word in the URL. Sent to Google as-is. |
fileType | string | optional | Restrict results to a file type, e.g. pdf, doc, xls. Sent to Google as-is. |
excludeTerms | string | optional | Words 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.