# Google Search Scraper (`headlessagent/google-search-scraper`) Actor

Collect ordered organic Google Search results and conservatively recognized SERP features.

- **URL**: https://apify.com/headlessagent/google-search-scraper.md
- **Developed by:** [Headless Agent](https://apify.com/headlessagent) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 90.3% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.60 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Google Search Scraper

Collect Google web, news, image, video, shopping and local results for research, monitoring, discovery and comparison. Run one query or a batch, choose country and language, and download individual results or complete search responses.

### What you can search

| Search type | What you get |
| --- | --- |
| **Web** | Ranked pages with titles, links, displayed links, publisher names, snippets, highlighted terms, dates and sitelinks. Sitelinks stay attached to their parent result. |
| **News** | Articles with headline, link, publisher, date, summary and thumbnail. Useful for tracking companies, topics and current coverage. |
| **Images** | Images with title, source page, source name and thumbnail, plus the original image link and size when available. Image searches read one page of results. |
| **Videos** | Videos with title, link, platform, channel, publication date, length, snippet and thumbnail. |
| **Shopping** | Products with title, store, product link, price, previous price, rating, review count, delivery text and thumbnail when shown. Prices and availability depend on the country and city you choose. |
| **Places** | Businesses with name, category, address, phone, opening hours, rating, review count, website, map link and thumbnail. Put a place in the search phrase or fill in **City or region** for more relevant results. |

### Input

| Field | Type | Default | What it does |
| --- | --- | --- | --- |
| `queries` | list of text | required | One or more search phrases, searched in order. |
| `searchType` | `web`, `news`, `images`, `videos`, `shopping` or `places` | `web` | Which kind of results to collect. |
| `maxResultsPerQuery` | number, 1–200 | 10 | How many results to collect for each phrase. Further pages are read automatically when one page is not enough, up to 5 pages per phrase. Google may return fewer. |
| `startPage` | number, 1–10 | 1 | The result page to start from; earlier pages are skipped, not read. Deeper pages often return few or no results. Images and Places always start at page 1. |
| `country` | country code | `us` | Shows results as seen from this country. The form lists country names, for example **Indonesia (id)**. |
| `language` | language code | `en` | Language of result pages and labels. The form lists language names, for example **English (en)**. |
| `location` | text | empty | Optional city or region, for example `Austin, Texas, United States`, to get results for that area. |
| `safeSearch` | `off` or `filter` | `off` | `filter` removes explicit results. |

Example input:

```json
{
  "queries": ["coffee shops in Jakarta", "bakeries in Jakarta"],
  "searchType": "places",
  "maxResultsPerQuery": 10,
  "country": "id",
  "language": "en",
  "safeSearch": "off"
}
```

Every phrase gets its own quota: this example returns up to 10 places for each of the two phrases, up to 20 rows in total.

To skip the first two pages, set `"startPage": 3`. Collection starts at page 3 and moves on to page 4 only if page 3 has fewer results than `maxResultsPerQuery`. The `page` field in each result shows the real page number, and `position` restarts at 1 on every page.

Country, language and city are separate settings: choosing one does not change the others. Invalid values stop the run with a message that names the field, for example `country is not a supported country code: zz`.

### Outputs

The **default dataset** contains one flat row per selected result, preserving fields such as `position`, `title`, `link`, `source`, `snippet`, `original`, `price` and `address` as appropriate for the search type. Each row also contains `query`, `page`, `result_type`, `responseId` and `scrapedAt`. `result_type` is one of `organic_results`, `news_results`, `images_results`, `video_results`, `shopping_results` or `local_results`. Positions restart at 1 on each page.

The **`serp-responses` dataset** contains one complete response for every visited query/page. Responses include `search_metadata`, `search_parameters`, `search_information`, the selected result group, and available related questions, related searches, knowledge graphs, top stories, AI summaries, inline videos, local places and pagination. The **`SERP_RESPONSE`** record in the default key-value store contains the latest complete response. Flat rows' `responseId` matches `search_metadata.id` in the complete response.

The **`serp-features` dataset** contains page-level extras separately from individual result rows: one row per related question, related search, knowledge graph, top story, AI overview, inline video or web local-pack place. Each feature retains its full detail in `data`, including AI text blocks and references, knowledge attributes and profiles, video metadata, story details or place information. `SERP_FEATURES` groups the extras by query and page. Dedicated local-search places appear as the selected flat results; web local packs remain page features.

The two named datasets accumulate across runs. Complete responses have unique IDs, and feature rows include `runId` and `responseId`. `RUN-REPORT` identifies both named datasets and records result counts, response IDs, timing, empty results and blocking or extraction errors. The run log stays short: one line when the search starts, one line per page (results, status, time) and one summary line; per-page details and the list of result hosts are in `RUN-REPORT`. Full page responses and features retain every extracted entry from visited pages; `maxResultsPerQuery` limits only the rows in the default dataset.

### Limitations

Sponsored placements are excluded across all search types.

Google controls the number and content of results. A requested page or item limit is a cap, not a guarantee. Some fields and whole search types can be unavailable for a query, country or session. Later pages may contain fewer results. Missing details are omitted, and a genuinely empty response is reported without inventing results.

Searches run one after another. Google sometimes refuses a search; such searches are reported in `RUN-REPORT` as blocked, and if every search is refused the run fails.

This Actor collects search result information; it does not download original image files, verify product stock or inspect every destination page. Rankings and optional features can change between runs.

# Actor input Schema

## `queries` (type: `array`):

Type one or more phrases to search for, one per line, exactly as you would in a search box.

## `searchType` (type: `string`):

Choose which kind of results you want, such as web pages, news articles or local places.

## `maxResultsPerQuery` (type: `integer`):

How many results to collect for each phrase, reading further pages automatically when needed, although there may be fewer results than this.

## `startPage` (type: `integer`):

The first page of results for each phrase, from 1 to 10; deeper pages often return little or nothing, and image and place searches always start from page 1.

## `country` (type: `string`):

Results are shown as they appear to someone searching from this country.

## `language` (type: `string`):

The language used for result pages and labels.

## `location` (type: `string`):

Enter a city or region, for example Austin, Texas, United States, to get results for that area.

## `safeSearch` (type: `string`):

Choose whether explicit results are filtered out.

## Actor input object example

```json
{
  "queries": [
    "best running shoes"
  ],
  "searchType": "web",
  "maxResultsPerQuery": 10,
  "startPage": 1,
  "country": "us",
  "language": "en",
  "safeSearch": "off"
}
```

# Actor output Schema

## `results` (type: `string`):

Individual results for the chosen search type. Fields retain their reference names; result_type identifies the vertical.

## `response` (type: `string`):

Full SearchResponse for the last query/page. Every complete response is also appended to the named serp-responses dataset.

## `features` (type: `string`):

Related questions/searches, full knowledge graphs, top stories, AI overview, inline videos and web local packs. Nonempty entries also appear in serp-features.

## `report` (type: `string`):

Counts, per-page diagnostics (status, timing, final URL, navigation trace, HTML snapshot key), response IDs, result hosts and the IDs of the named serp-responses and serp-features datasets. The run log shows only a short line per page and a summary.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queries": [
        "best running shoes"
    ],
    "searchType": "web",
    "maxResultsPerQuery": 10,
    "startPage": 1,
    "country": "us",
    "language": "en",
    "safeSearch": "off"
};

// Run the Actor and wait for it to finish
const run = await client.actor("headlessagent/google-search-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "queries": ["best running shoes"],
    "searchType": "web",
    "maxResultsPerQuery": 10,
    "startPage": 1,
    "country": "us",
    "language": "en",
    "safeSearch": "off",
}

# Run the Actor and wait for it to finish
run = client.actor("headlessagent/google-search-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queries": [
    "best running shoes"
  ],
  "searchType": "web",
  "maxResultsPerQuery": 10,
  "startPage": 1,
  "country": "us",
  "language": "en",
  "safeSearch": "off"
}' |
apify call headlessagent/google-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,headlessagent/google-search-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/iDB4U30IxdRWPv0u6/builds/2beGAffm5HfuCOmLO/openapi.json
