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

This Apify actor performs customizable Google searches and returns results in JSON format. It supports filters for site-specific searches, language, country codes, safe search, and more. Ideal for automated data extraction from Google search results.

- **URL**: https://apify.com/miracyuzakli/google-search-scraper.md
- **Developed by:** [Muhammet Miraç Yüzaklı](https://apify.com/miracyuzakli) (community)
- **Categories:** Automation, News
- **Security:** Full permissions
- **Stats:** 40 total users, 1 monthly users, 100.0% runs succeeded, 5 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

#### Information for Google Search Scraper Actor

##### Overview

The **Google Search Scraper Actor** performs automated Google searches based on user-defined queries and returns the results in a structured JSON format. It supports various filters such as site-specific searches, language preferences, country codes, and safe search options. This actor is ideal for developers and analysts who need automated and customizable Google search data extraction.

##### Input Parameters

- **`query`**: *(string, required)* The search term to be used in the Google search.
- **`num_pages`**: *(integer, optional)* The number of search result pages to retrieve (default is 1).
- **`site_filter`**: *(string, optional)* Restrict results to a specific site (e.g., `example.com`).
- **`country_code`**: *(string, optional)* The country code for localized searches (default is 'US').
- **`language`**: *(string, optional)* The language for the search results (default is 'en').
- **`search_type`**: *(string, optional)* Specify the type of search (e.g., 'news', 'images').
- **`date_range`**: *(string, optional)* Limit results to a specific date range (e.g., 'w' for the last week).
- **`safe_search`**: *(boolean, optional)* Enable safe search to filter explicit content (default is False).

##### Example Input

```json
{
  "query": "python programming",
  "num_pages": 2,
  "site_filter": "python.org",
  "country_code": "US",
  "language": "en",
  "search_type": "news",
  "date_range": "w",
  "safe_search": true
}
```

##### Example Output

The actor returns a JSON array where each element contains search results, structured as follows:

```json
[
     {
        "term": "python site:python.org",
        "url": "https://docs.python.org/",
        "device": "DESKTOP",
        "page": 1,
        "type": "organic",
        "domain": "google.com",
        "countryCode": "US",
        "resultsPerPage": "10",
        "title": "3.12.4 Documentation",
        "displayedUrl": "https://docs.python.org",
        "description": "3 days ago — Python setup and usage. How to install, configure, and use Python. Python HOWTOs. In-depth topic manuals. Installing Python modules. Third-party modules and ...",
        "emphasizedKeywords": "python site:python.org",
        "siteLinks": [],
        "position": 1
    },
    {
        "term": "python site:python.org",
        "url": "https://www.python.org/downloads/release/python-3130rc1/",
        "device": "DESKTOP",
        "page": 1,
        "type": "organic",
        "domain": "google.com",
        "countryCode": "US",
        "resultsPerPage": "10",
        "title": "Python Release Python 3.13.0rc1",
        "displayedUrl": "https://www.python.org › downloads › python-3130rc1",
        "description": "2 days ago — Release Date: Aug. 1, 2024. This is the first release candidate of Python 3.13.0. This release, 3.13.0rc1, is the penultimate release preview.",
        "emphasizedKeywords": "python site:python.org",
        "siteLinks": [],
        "position": 2
    },
    {
        "term": "python site:python.org",
        "url": "https://docs.python.org/3/library/functions.html",
        "device": "DESKTOP",
        "page": 1,
        "type": "organic",
        "domain": "google.com",
        "countryCode": "US",
        "resultsPerPage": "10",
        "title": "Built-in Functions — Python 3.12.4 documentation",
        "displayedUrl": "https://docs.python.org › library › functions",
        "description": "3 days ago — The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order.,,,, Built-in ...",
        "emphasizedKeywords": "python site:python.org",
        "siteLinks": [],
        "position": 3
    },
    ...
]
```

#### Key Features

- **Flexible Querying**: Tailor your search with multiple parameters to get the most relevant results.
- **JSON Format**: Results are returned in a clean and structured JSON format, ready for further processing.
- **Pagination Support**: Retrieve multiple pages of Google search results effortlessly.
- **Filtering Options**: Use filters such as site-specific, language, country code, and more to refine your search.

This actor is highly customizable, making it an essential tool for those needing to automate and extract Google search data programmatically.

# Actor input Schema

## `query` (type: `string`):

The search term you want to query on Google.

## `num_pages` (type: `integer`):

Number of result pages to retrieve.

## `site_filter` (type: `string`):

Filter results by a specific site.

## `country_code` (type: `string`):

Country code for geolocation-based searches.

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

Language for the search results.

## `search_type` (type: `string`):

Specify the type of search (e.g., 'news', 'images').

## `date_range` (type: `string`):

Limit results to a specific date range (e.g., 'w' for last week).

## `safe_search` (type: `boolean`):

Enable safe search to filter explicit content.

## Actor input object example

```json
{
  "query": "python",
  "num_pages": 1,
  "site_filter": "",
  "country_code": "US",
  "language": "en",
  "search_type": "",
  "date_range": "",
  "safe_search": false
}
```

# 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 = {
    "query": "python",
    "num_pages": 1,
    "site_filter": "",
    "country_code": "US",
    "language": "en",
    "search_type": "",
    "date_range": "",
    "safe_search": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("miracyuzakli/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 = {
    "query": "python",
    "num_pages": 1,
    "site_filter": "",
    "country_code": "US",
    "language": "en",
    "search_type": "",
    "date_range": "",
    "safe_search": False,
}

# Run the Actor and wait for it to finish
run = client.actor("miracyuzakli/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 '{
  "query": "python",
  "num_pages": 1,
  "site_filter": "",
  "country_code": "US",
  "language": "en",
  "search_type": "",
  "date_range": "",
  "safe_search": false
}' |
apify call miracyuzakli/google-search-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,miracyuzakli/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/IR6iFkfszEE76Ibkf/builds/gpIzpqV5CSYen4ehM/openapi.json
