Skip to content
google scrapingpythonweb scraping

How to Scrape Google Search Results with Proxies (Python)

How to request a Google result page through a residential proxy, pace the queries, and count blocks on your own keywords.

Google scores the network, the client, and the pace of the queries. A hosting ASN is one of those scores. A residential address is not a promise that the next query will be accepted. ProxyLabs does not publish how many queries a fresh address survives.

Count it on the keywords you care about:

What you write downWhy
Status of the first query from a fresh addressArrival reputation, before your crawl has a pattern
Queries until sorry/index or a 429, at one paceYour ceiling at that pace
Sticky session versus a new address per queryPagination has to stay on one address
City on the exit versus the city in the queryLocal packs follow the IP

Change one thing at a time. A count from someone else's week is not your keyword set.

Why Datacenter IPs Fail on Google

Google doesn't just check if your IP is residential or datacenter. They cross-reference multiple signals:

  1. ASN reputation — Google scores the network the address belongs to. AWS (AS16509), Google Cloud (AS15169), and Hetzner (AS24940) are hosting networks. A new address in those ranges is still a hosting address.

  2. Request fingerprint consistency — Google checks if the HTTP headers, TLS fingerprint, and cookie behavior match what a real browser from that IP's ISP would produce. A Python requests call from a Comcast residential IP still looks suspicious if the TLS fingerprint screams python-requests/2.31.

  3. Query pattern analysis — Real users don't search 200 keywords per minute from the same IP. Google's rate detection is per-IP and per-session, and they correlate across IPs from the same subnet.

  4. Geographic consistency — If your IP geolocates to London but your Accept-Language header says en-US and your timezone cookie says America/Chicago, that's a signal.

Basic Google Scraper with Residential Proxies

python
import requests
from bs4 import BeautifulSoup
import time
import random

PROXY = {
    'http': 'http://your-username-country-us:[email protected]:8080',
    'https': 'http://your-username-country-us:[email protected]:8080',
}

HEADERS = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
    'Accept-Language': 'en-US,en;q=0.9',
    'Accept-Encoding': 'gzip, deflate, br',
    'DNT': '1',
    'Connection': 'keep-alive',
    'Upgrade-Insecure-Requests': '1',
}

def scrape_google(query, num_results=10):
    url = 'https://www.google.com/search'
    params = {
        'q': query,
        'num': num_results,
        'hl': 'en',
        'gl': 'us',
    }

    response = requests.get(url, params=params, headers=HEADERS, proxies=PROXY, timeout=15)

    if response.status_code == 429:
        print(f"Rate limited. Status: {response.status_code}")
        return None

    if response.status_code != 200:
        print(f"Failed: {response.status_code}")
        return None

    soup = BeautifulSoup(response.text, 'html.parser')
    results = []

    for g in soup.select('div.g'):
        title_el = g.select_one('h3')
        link_el = g.select_one('a[href]')
        snippet_el = g.select_one('div[data-sncf]') or g.select_one('.VwiC3b')

        if title_el and link_el:
            results.append({
                'title': title_el.text,
                'url': link_el['href'],
                'snippet': snippet_el.text if snippet_el else '',
            })

    return results

This works for a handful of queries. For anything beyond 50 queries, you need rate limiting and session management.

Rate Limiting Strategy That Actually Works

The single biggest mistake in Google scraping: fixed delays. If you time.sleep(2) between every request, that's more suspicious than variable timing because real humans don't operate on fixed intervals.

python
import random
import time

class GoogleScraper:
    def __init__(self, proxy_username, proxy_password):
        self.proxy_username = proxy_username
        self.proxy_password = proxy_password
        self.session_count = 0
        self.request_count = 0

    def _get_proxy(self, country='us', session_id=None):
        username = self.proxy_username
        code = 'gb' if country.lower() == 'uk' else country.lower()
        if code:
            username += f'-country-{code}'
        if session_id:
            username += f'-ttl-3600-session-{session_id}'
        # us, ca, mx, br, ar, co, cl, pe → us.proxylabs.app. Every other code → eu.
        americas = {'us', 'ca', 'mx', 'br', 'ar', 'co', 'cl', 'pe'}
        host = 'us.proxylabs.app' if code in americas else 'eu.proxylabs.app'

        proxy_url = f'http://{username}:{self.proxy_password}@{host}:8080'
        return {'http': proxy_url, 'https': proxy_url}

    def _human_delay(self):
        """Mimic human browsing: mostly short pauses, occasional longer ones."""
        base = random.uniform(3, 7)
        # 15% chance of a longer pause (reading results, thinking)
        if random.random() < 0.15:
            base += random.uniform(10, 25)
        # 5% chance of a very long pause (distracted)
        if random.random() < 0.05:
            base += random.uniform(30, 60)
        time.sleep(base)

    def _rotate_session(self):
        """New session every 15-25 requests to avoid per-session detection."""
        self.session_count += 1
        return f'google-{self.session_count}-{random.randint(1000, 9999)}'

    def scrape_batch(self, queries, country='US'):
        results = {}
        session_id = self._rotate_session()
        requests_this_session = 0

        for query in queries:
            # Rotate session every 15-25 requests
            if requests_this_session > random.randint(15, 25):
                session_id = self._rotate_session()
                requests_this_session = 0
                # Longer pause on session rotation
                time.sleep(random.uniform(10, 20))

            proxy = self._get_proxy(country=country, session_id=session_id)
            result = self._single_query(query, proxy)

            if result is None:
                # Rate limited — back off, rotate, retry
                print(f"Rate limited on: {query}. Backing off...")
                time.sleep(random.uniform(30, 60))
                session_id = self._rotate_session()
                proxy = self._get_proxy(country=country, session_id=session_id)
                result = self._single_query(query, proxy)

            results[query] = result
            requests_this_session += 1
            self._human_delay()

        return results

    def _single_query(self, query, proxy):
        # ... same as scrape_google() above
        pass

Pacing

There is no query ceiling that holds for every keyword. Start slower than a person researching, and write down the pace that still returns a result page.

  • Space queries from one address. A few seconds is a start. Shorten the gap only after a run stays clean.
  • On a 429, wait. Rotating spends a new address on a limit that belonged to the previous one.
  • On sorry/index, retire that session id and continue on a new one.
  • Keep the User-Agent, the language, and the country code in agreement. A gb exit with en-US is a mismatch you can see without a lab.

Handling Google's CAPTCHA

When Google serves a CAPTCHA, it redirects to sorry/index with a 429 or 302 status. Don't try to solve it — rotate the IP and move on.

python
def handle_response(self, response, query, proxy):
    if response.status_code == 429 or 'sorry/index' in response.url:
        return 'captcha'
    if response.status_code == 200 and 'unusual traffic' in response.text.lower():
        return 'soft_block'
    if response.status_code == 200:
        return 'success'
    return 'error'

A CAPTCHA-solving service adds a fee and a wait on every challenge. Pacing that stays on a result page spends neither.

Country-Targeted SERP Scraping

Google returns different results based on the IP's geolocation, not just the gl parameter. The gl parameter is a hint, but Google gives precedence to IP geolocation when they conflict. If you need accurate local results for SEO rank tracking, the IP must match the target country.

python
# Scrape UK SERPs with a UK residential IP
proxy_uk = self._get_proxy(country='GB', session_id='uk-serp-001')

# Scrape German SERPs — note: use google.de for better accuracy
# German users typically use google.de, not google.com
params = {
    'q': query,
    'num': 10,
    'hl': 'de',
    'gl': 'de',
}
response = requests.get('https://www.google.de/search', params=params,
                        headers=HEADERS_DE, proxies=self._get_proxy(country='DE'))

For a local pack, the exit has to be in that city. New York is the documented slug. Other cities are the slugs the dashboard lists.

python
# Americas, 60 minutes from the start. Reusing the session id does not add time.
proxy_nyc = {
    "http": "http://your-username-country-us-region-ny-city-newyork-ttl-3600-session-nyc-local:[email protected]:8080",
    "https": "http://your-username-country-us-region-ny-city-newyork-ttl-3600-session-nyc-local:[email protected]:8080",
}

A United Kingdom query uses -country-gb on eu.proxylabs.app. The code uk is not a country code here. City targeting is available for the countries the dashboard lists, which is what local SEO needs when the pack changes between cities.

Scaling to 10K+ Queries/Day

At scale, the bottleneck isn't proxy quality — it's orchestration. You need parallel workers with independent sessions and coordinated rate limiting.

python
from concurrent.futures import ThreadPoolExecutor
import threading

class ScaledGoogleScraper:
    def __init__(self, proxy_username, proxy_password, max_workers=5):
        self.scraper = GoogleScraper(proxy_username, proxy_password)
        self.max_workers = max_workers
        self.global_rate = threading.Semaphore(max_workers)

    def scrape_all(self, queries, country='US'):
        # Split queries across workers
        chunks = [queries[i::self.max_workers] for i in range(self.max_workers)]

        with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
            futures = [
                executor.submit(self.scraper.scrape_batch, chunk, country)
                for chunk in chunks
            ]
            results = {}
            for future in futures:
                results.update(future.result())
        return results

Key numbers for planning:

  • 5 workers × 8 requests/min = 40 queries/min = ~2,400/hour
  • At 3-7 second delays, each worker handles ~10-15 queries/min peak
  • Factor in backoffs and you'll average 8,000-12,000 queries/day with 5 workers
  • Bandwidth per query: ~50-100KB = negligible on ProxyLabs' per-GB pricing

What About Google's API?

Google's Custom Search JSON API returns organic results and has its own quota and price. Read the current quota before you plan around it. It does not return People Also Ask, featured snippets, or the local pack.

For rank tracking at scale, ad intelligence, or SERP feature monitoring, scraping is the only option. The official API simply doesn't return the data you need.

Common Pitfalls

Using requests without TLS fingerprint masking — Google can fingerprint the TLS handshake of Python's requests library. For high-volume scraping, consider curl_cffi or tls_client which mimic Chrome's TLS fingerprint. See our Playwright proxy guide for browser-based approaches that avoid this entirely.

Scraping google.com for non-US results — Real users in Germany use google.de, users in France use google.fr. Using google.com with a German IP is a subtle but detectable anomaly.

Not matching Accept-Language to IP geo — If your IP is in Japan, your Accept-Language should include ja. This is basic but frequently missed.

Parsing HTML structure changes — Google A/B tests layout constantly. Don't rely on specific CSS class names. Build resilient parsers that extract based on DOM hierarchy rather than class selectors, and monitor for parse failures.

For a complete scraping setup with browser automation and all anti-detection measures, check the Playwright proxy guide. To test your proxy setup before running at scale, use the proxy tester.

Useful guide? Share it with your team.

Share
← Back to all articlesBack to top ↑
All articles ↗
SEO

Residential Proxies for SEO & SERP Monitoring

How to use residential proxies for accurate SERP tracking, rank monitoring, and SEO audits. Covers geo-targeting, avoiding personalization bias, and code examples.

9 min read
amazon

How to Scrape Amazon Prices in 2026 (Without Getting Blocked)

A working guide to scraping Amazon product prices with residential proxies. Covers their anti-bot stack, request patterns, and code examples in Python.

6 min read
scrapy

Scrapy Proxy Middleware: Rotating IPs Without Bans

Build a Scrapy proxy middleware that rotates residential IPs per request. Includes retry logic, geo-targeting, bandwidth tracking, and ban detection.

6 min read