Guide
How to Scrape Google Search Results
A complete guide to scraping Google search results (SERPs) using Python, covering methods from API-based to custom scraping approaches.
Google search result scraping (SERP scraping) is one of the most valuable and challenging scraping tasks. Google aggressively blocks automated queries, making a reliable approach essential.
Why SERP Scraping Is Difficult
Google employs some of the strongest anti-bot protections on the web:
- CAPTCHAs triggered after just a few requests
- IP blocking for detected bot traffic
- Constantly changing HTML structure
- JavaScript-rendered results and featured snippets
Method 1: ScraperAPI Google Search Endpoint (Recommended)
ScraperAPI provides a dedicated SERP endpoint that returns structured JSON data:
import requests
API_KEY = "YOUR_SCRAPERAPI_KEY"
response = requests.get("https://api.scraperapi.com/structured/google/search", params={
"api_key": API_KEY,
"query": "best web scraping tools 2026",
"country": "us",
"num": "10"
})
data = response.json()
for result in data.get("organic_results", []):
print(f"Position: {result['position']}")
print(f"Title: {result['title']}")
print(f"URL: {result['link']}")
print(f"Snippet: {result['snippet']}")
print("---")
Method 2: Raw HTML Parsing
If you need more control, scrape through a proxy API and parse the HTML:
import requests
from bs4 import BeautifulSoup
response = requests.get("https://api.scraperapi.com", params={
"api_key": "YOUR_SCRAPERAPI_KEY",
"url": "https://www.google.com/search?q=web+scraping+python",
"render": "true"
})
soup = BeautifulSoup(response.text, "html.parser")
for result in soup.select("div.g"):
title_el = result.select_one("h3")
link_el = result.select_one("a")
snippet_el = result.select_one("div.VwiC3b")
if title_el and link_el:
print(f"Title: {title_el.text}")
print(f"URL: {link_el['href']}")
if snippet_el:
print(f"Snippet: {snippet_el.text}")
print("---")
Scraping Google with ScrapingAnt
ScrapingAnt's headless Chrome can also handle Google SERPs effectively:
import requests
from bs4 import BeautifulSoup
response = requests.get("https://api.scrapingant.com/v2/general", params={
"x-api-key": "YOUR_SCRAPINGANT_KEY",
"url": "https://www.google.com/search?q=web+scraping+tools",
"browser": "true",
"proxy_type": "residential"
})
html = response.json()["content"]
soup = BeautifulSoup(html, "html.parser")
for result in soup.select("div.g"):
title = result.select_one("h3")
if title:
print(title.text)
Best Practices for SERP Scraping
- Use structured endpoints when available (ScraperAPI's SERP API)
- Rotate through different country targets to distribute load
- Add delays between requests even when using APIs
- Cache results to avoid redundant requests
- Respect Google's Terms of Service and use official APIs where possible
Verdict
ScraperAPI's structured Google Search endpoint is the most reliable and efficient way to scrape SERPs. It handles all anti-bot measures and returns clean JSON data. For custom parsing needs, ScrapingAnt's headless Chrome with residential proxies is an excellent fallback.