Skip to content

Latest commit

 

History

History
182 lines (116 loc) · 7.85 KB

File metadata and controls

182 lines (116 loc) · 7.85 KB

Google Search Scraper Python

Run the hosted Google Search SERP Scraper on Apify without writing code, or integrate it with Python, JavaScript or cURL to collect structured organic Google results.

Browse the technical examples and sample Dataset

This repository contains executable API examples, verified sample input, real Dataset output and a CSV export. It documents the public integration surface without exposing the Actor's private implementation, proxy configuration or credentials.

What this repository helps you do

  • Collect organic Google results with query, page, position, title, URL and description.
  • Monitor keyword rankings with consistent country and language settings.
  • Process one query or batch up to 10,000 queries in a run.
  • Request pages 1–10 while keeping the total query/page workload within 10,000 pages.
  • Export results to JSON, CSV, Excel or JSONL for reporting and data pipelines.

Example result

The complete verified sample is available in data/sample-output.json, with the same fields in data/sample-output.csv.

{
  "query": "apify web scraping",
  "page": 1,
  "position": 1,
  "title": "Portal Inmobiliario Property Search Scraper - Apify",
  "url": "https://apify.com/ecomscrape/portalinmobiliario-property-search-scraper",
  "description": "The ignore_url_failures parameter: If set to true , the scraper will continue running even if some URLs fail to be scraped after the maximum number of retries ..."
}

The sample rows come from a successful published Actor run. Google rankings and snippets change over time, so the fixture proves the output contract rather than a current ranking.

Run Google Search Scraper without code

  1. Open Google Search SERP Scraper on Apify.
  2. In the Input tab, add one or more values to Search Queries.
  3. Choose the start page, end page, language and country.
  4. Click Start.
  5. Open Dataset to inspect the organic results and export them.

Use data/sample-input.json for a small first request and docs/no-code-guide.md for the complete web-interface walkthrough.

Try Google Search Scraper with Apify's free plan

Apify's Free plan currently includes $5 in monthly prepaid usage and does not require a credit card. This can cover a small first test while credit is available, but it is not unlimited free usage.

Unused credit expires at the end of the billing cycle. Check the current Apify pricing before running a larger batch.

Quick start for developers

Python

1. Install the client

pip install -r examples/python/requirements.txt

2. Set your Apify token

Linux/macOS:

export APIFY_API_TOKEN="your-token"

Windows PowerShell:

$env:APIFY_API_TOKEN = "your-token"

3. Run the example

python examples/python/google_search_scraper.py

The script reads data/sample-input.json, runs the hosted Actor and prints each returned Dataset item as JSON.

Input example

{
  "queries": [
    "apify web scraping"
  ],
  "startPage": 1,
  "endPage": 1,
  "language": "es",
  "country": "es"
}

See docs/input-reference.md for defaults, validation rules and workload limits.

Request examples

cURL

examples/curl-request.md uses the synchronous Dataset endpoint and the checked-in sample input.

Python

examples/python/google_search_scraper.py runs the sample input. examples/python/batch_google_search.py demonstrates multiple queries, and examples/python/export_google_serp_csv.py exports Dataset JSON to CSV.

JavaScript

examples/javascript/request.mjs uses the official Apify JavaScript client.

All request examples call the hosted Actor. They do not contain a token, proxy URL, private endpoint or scraping implementation.

Output fields

Field Meaning
query Original search query associated with the result.
page Google result page number from 1 to 10.
position Organic position across the requested page range.
title Organic result title, or null when unavailable.
url Organic destination URL, or null when unavailable.
description Visible Google snippet, or null when unavailable.

The default Key-Value Store also contains a SUMMARY record for run-level status and counts. See docs/output-reference.md.

Common use cases

Read docs/use-cases.md for complete workflows covering:

  • Google keyword rank tracking by market.
  • Competitor and domain visibility analysis.
  • Batch keyword research and CSV export.
  • Recurring SERP monitoring.

How to scrape Google search results with Python

Use examples/python/google_search_scraper.py for a complete hosted integration. The example loads JSON input, calls the Actor and iterates through the default Dataset without reproducing the scraping infrastructure locally.

For multiple keywords, use examples/python/batch_google_search.py. Keep one country, language and page range per run so the rows are comparable.

Google SERP API JSON example

Each organic result is an independent JSON object with six stable fields: query, page, position, title, url and description. Inspect data/sample-output.json for complete real rows from a successful run.

Export Google search results to CSV

Run python examples/python/export_google_serp_csv.py. It reads the sample JSON by default and writes data/exported-google-results.csv, or accepts custom input and output paths.

FAQ

See docs/faq.md for answers about no-code usage, Python integration, localization, pagination, billing, JSON output and CSV export.

Limits and pricing

  • Up to 10,000 queries per run.
  • Pages 1–10.
  • At most 10,000 query/page combinations per run.
  • Up to 10 organic rows per requested page, with a theoretical maximum of 100,000 delivered rows.
  • Current public price: $0.60 per 1,000 organic results delivered.

One successfully delivered Dataset item triggers one serp-result event at $0.0006. Failed pages, undelivered results and the SUMMARY record do not trigger that event. Verify the current contract on the Actor page before production use.

Hosted version

Use the hosted Actor for batching, localization, pagination, schedules, API access, webhooks and managed Dataset storage:

Run Google Search SERP Scraper on Apify

Responsible use

Google controls result availability and layout, so rankings, titles and snippets can vary by time and market. The Actor returns organic results only; it does not include ads, shopping modules, maps, local packs or knowledge panels.

Use returned data lawfully and respect the terms, access rules and privacy obligations that apply to your use case. Never commit an Apify token or other credentials to this repository.

Support

For a problem with these examples, open a GitHub issue with sanitized input and the error message. For an Actor execution problem, include the Apify run ID but never include your token.

License

This repository is released under the MIT License.