Search engines personalize results based on location, search history, device type, and dozens of other signals. If you're tracking keyword rankings from your office IP, you're seeing results tailored to your location and browsing profile — not what your target audience sees. A keyword that ranks #3 from your London office might be #8 for a user in Houston and #12 for someone in Sydney.
Residential proxies solve this by letting you check rankings from real IPs in specific cities and countries, seeing exactly what local users see.
Why Datacenter Proxies Fail for SERP Monitoring
Google treats a hosting ASN differently from a household ASN, and it localizes from the IP. A datacenter exit can be challenged early, and it can miss the local pack, because no household user sits in that range. A residential exit can still be challenged if the pace is wrong. ProxyLabs does not publish a CAPTCHA rate for either.
If you report rankings to a client, the exit's city has to be the city in the report. The gl and uule parameters are hints. When they disagree with the IP, the IP usually wins. Confirm the city on the exit before you store the rank.
For more on the technical differences, see our residential vs datacenter proxies comparison.
Basic SERP Scraping Setup
import requests
from bs4 import BeautifulSoup
import time
import random
PROXY_USER = "your-username"
PROXY_PASS = "your-password"
def proxy_for(country, region=None, city=None, session_id=None):
"""Country codes are lowercase ISO alpha-2. UK is gb.
us, ca, mx, br, ar, co, cl, pe use us.proxylabs.app. Every other code uses eu.proxylabs.app.
"""
code = "gb" if country.lower() == "uk" else country.lower()
user = f"{PROXY_USER}-country-{code}"
if region:
user += f"-region-{region}"
if city:
user += f"-city-{city}"
if session_id:
user += f"-ttl-3600-session-{session_id}"
host = "us.proxylabs.app" if code in {"us", "ca", "mx", "br", "ar", "co", "cl", "pe"} else "eu.proxylabs.app"
url = f"http://{user}:{PROXY_PASS}@{host}:8080"
return {"http": url, "https": url}
HEADERS = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'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',
}
def get_google_rankings(keyword, country="us", region=None, city=None, num_results=20):
"""Scrape a result page. City slugs come from the dashboard. New York is region ny, city newyork."""
proxy = proxy_for(country, region=region, city=city, session_id="serp")
params = {
'q': keyword,
'num': num_results,
'hl': 'en',
'gl': 'uk' if country.lower() in {'gb', 'uk'} else country.lower(),
}
try:
r = requests.get(
'https://www.google.com/search',
params=params,
headers=HEADERS,
proxies=proxy,
timeout=15,
)
if r.status_code != 200:
return {'error': f'HTTP {r.status_code}', 'keyword': keyword}
soup = BeautifulSoup(r.text, 'html.parser')
# Check for CAPTCHA
if soup.find('form', {'id': 'captcha-form'}):
return {'error': 'captcha', 'keyword': keyword}
results = []
for i, div in enumerate(soup.select('div.g'), start=1):
link = div.select_one('a')
title = div.select_one('h3')
snippet = div.select_one('.VwiC3b')
if link and title:
results.append({
'position': i,
'url': link.get('href', ''),
'title': title.get_text(strip=True),
'snippet': snippet.get_text(strip=True) if snippet else '',
})
return {'keyword': keyword, 'country': country, 'city': city, 'results': results}
except requests.exceptions.RequestException as e:
return {'error': str(e), 'keyword': keyword}
# Track rankings for a keyword from different locations
# New York is the documented city slug. Add another city only after the dashboard lists it.
locations = [
{"country": "us", "region": "ny", "city": "newyork"},
{"country": "gb"},
{"country": "de"},
]
keyword = "best project management software"
for place in locations:
data = get_google_rankings(keyword, **place)
label = place.get("city") or place["country"]
if "error" not in data:
print(f"\n{label}:")
for r in data['results'][:5]:
print(f" #{r['position']}: {r['url'][:60]}")
else:
print(f"\n{label}: Error — {data['error']}")
time.sleep(random.uniform(3, 7))
Tracking Your Rankings Over Time
The real value comes from daily tracking. Here's a more complete rank tracker:
import requests
from bs4 import BeautifulSoup
import json
import time
import random
from datetime import datetime
PROXY_USER = "your-username"
PROXY_PASS = "your-password"
def proxy_for(country, region=None, city=None, session_id=None):
code = "gb" if country.lower() == "uk" else country.lower()
user = f"{PROXY_USER}-country-{code}"
if region:
user += f"-region-{region}"
if city:
user += f"-city-{city}"
if session_id:
user += f"-ttl-3600-session-{session_id}"
host = "us.proxylabs.app" if code in {"us", "ca", "mx", "br", "ar", "co", "cl", "pe"} else "eu.proxylabs.app"
url = f"http://{user}:{PROXY_PASS}@{host}:8080"
return {"http": url, "https": url}
HEADERS = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.9',
'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',
}
def find_domain_rank(keyword, target_domain, country="us", region=None, city=None, max_results=50):
"""Find where a domain ranks. City slugs come from the dashboard."""
proxy = proxy_for(country, region=region, city=city, session_id="rank")
# Fetch up to 50 results to find deeper rankings
gl = "uk" if country.lower() in {"gb", "uk"} else country.lower()
params = {"q": keyword, "num": min(max_results, 100), "hl": "en", "gl": gl}
try:
r = requests.get('https://www.google.com/search', params=params,
headers=HEADERS, proxies=proxy, timeout=15)
if r.status_code != 200:
return None
soup = BeautifulSoup(r.text, 'html.parser')
if soup.find('form', {'id': 'captcha-form'}):
return None
for i, div in enumerate(soup.select('div.g'), start=1):
link = div.select_one('a')
if link:
href = link.get('href', '')
if target_domain in href:
return i
return -1 # Not found in results
except Exception:
return None
def daily_rank_check(keywords, target_domain, locations):
"""Run a full rank check across keywords and locations."""
today = datetime.now().strftime('%Y-%m-%d')
results = []
for keyword in keywords:
for place in locations:
rank = find_domain_rank(keyword, target_domain, **place)
entry = {
"date": today,
"keyword": keyword,
"country": place["country"],
"city": place.get("city"),
"rank": rank,
"domain": target_domain,
}
results.append(entry)
label = place.get("city") or place["country"]
status = f"#{rank}" if rank and rank > 0 else "Not found" if rank == -1 else "Error"
print(f" {keyword} ({label}): {status}")
# Delay between queries — Google rate limits aggressively
time.sleep(random.uniform(4, 8))
# Append to JSONL file for historical tracking
with open(f'rankings_{today}.jsonl', 'a') as f:
for entry in results:
f.write(json.dumps(entry) + '\n')
return results
# Configuration
keywords = [
'residential proxies',
'rotating proxy service',
'web scraping proxy',
'buy residential proxies',
]
target_domain = 'proxylabs.app'
locations = [
{"country": "us", "region": "ny", "city": "newyork"},
{"country": "gb"},
]
daily_rank_check(keywords, target_domain, locations)
Google SERP Features to Track
Modern SERPs aren't just 10 blue links. You need to track these features too:
| Feature | CSS selector (approximate) | Why it matters |
|---|---|---|
| Featured snippet | div.xpdopen | Position 0 — massive CTR |
| People Also Ask | div.related-question-pair | Expanding into this drives traffic |
| Local pack (map) | div.VkpGBb | Critical for local businesses |
| Knowledge panel | div.kp-wholepage | Brand queries |
| Shopping results | div.commercial-unit-desktop-top | E-commerce keywords |
| Video carousel | div.MjjYud video-voyager | Video SEO opportunities |
def detect_serp_features(soup):
"""Detect which SERP features appear for a query."""
features = {}
features['featured_snippet'] = bool(soup.select_one('div.xpdopen'))
features['people_also_ask'] = bool(soup.select_one('div.related-question-pair'))
features['local_pack'] = bool(soup.select_one('div.VkpGBb'))
features['knowledge_panel'] = bool(soup.select_one('div.kp-wholepage'))
features['shopping'] = bool(soup.select_one('div.commercial-unit-desktop-top'))
features['video_carousel'] = bool(soup.select('div[data-init-vis="true"] video-voyager'))
return features
Avoiding Google Detection
Google is more aggressive about blocking scrapers than most sites. These patterns keep one address for a short batch of queries, then ask for another:
Request timing
- Leave a gap between queries from the same address. A few seconds, varied, is a start. Shorten it only after a run stays clean. ProxyLabs does not publish the gap where challenges begin.
- A fixed interval is a pattern.
random.uniformis the small change. - Keep one sticky session for a short batch, then start a new session id. A new address on every query throws away the session a result page just set. The batch size is yours to pick. Seven is a starting point, not a measured optimum.
import uuid
def batch_search(keywords, country="us", batch_size=7):
"""One sticky session per batch. UK is gb. Americas use us.proxylabs.app."""
results = []
code = "gb" if country.lower() == "uk" else country.lower()
host = "us.proxylabs.app" if code in {"us", "ca", "mx", "br", "ar", "co", "cl", "pe"} else "eu.proxylabs.app"
for i in range(0, len(keywords), batch_size):
batch = keywords[i:i + batch_size]
session_id = uuid.uuid4().hex[:12]
proxy = {
"http": f"http://{PROXY_USER}-country-{code}-ttl-1800-session-{session_id}:{PROXY_PASS}@{host}:8080",
"https": f"http://{PROXY_USER}-country-{code}-ttl-1800-session-{session_id}:{PROXY_PASS}@{host}:8080",
}
for keyword in batch:
r = requests.get(
'https://www.google.com/search',
params={'q': keyword, 'num': 20, 'hl': 'en'},
headers=HEADERS,
proxies=proxy,
timeout=15,
)
results.append({'keyword': keyword, 'status': r.status_code, 'size': len(r.text)})
time.sleep(random.uniform(4, 8))
# Longer pause between batches
time.sleep(random.uniform(10, 20))
return results
Accept-Language Matching
If you're using a German IP but sending Accept-Language: en-US, Google notices the mismatch. Match the language header to your proxy country:
# Keys here are header labels. The proxy username still uses lowercase gb, not UK or GB.
LANGUAGE_MAP = {
"us": "en-US,en;q=0.9",
"gb": "en-GB,en;q=0.9",
"de": "de-DE,de;q=0.9,en;q=0.8",
"fr": "fr-FR,fr;q=0.9,en;q=0.8",
"jp": "ja-JP,ja;q=0.9,en;q=0.8",
"br": "pt-BR,pt;q=0.9,en;q=0.8",
}
def get_headers_for_country(country):
headers = HEADERS.copy()
headers['Accept-Language'] = LANGUAGE_MAP.get(country, 'en-US,en;q=0.9')
return headers
Bandwidth Estimation
SERP monitoring is bandwidth-efficient compared to full-page scraping:
| Scale | Queries/day | Bandwidth/day | Monthly cost (30 days, volume pricing) |
|---|---|---|---|
| Small (1 site, 50 keywords, 3 locations) | 150 | ~75 MB | ~£5.33/mo |
| Medium (5 sites, 200 keywords, 5 locations) | 5,000 | ~2.5 GB | ~£136/mo |
| Large (20 sites, 1000 keywords, 10 locations) | 200,000 | ~100 GB | ~£3,379/mo |
A result page is often a few hundred kilobytes. Measure yours. Residential bandwidth lists at £2.50/GB, is £1.00/GB from 5,000 GB, and is £0.95/GB from 10,000 GB. The monthly figures above use that public curve on the month's total. At a few thousand gigabytes the rate is still above £0.95/GB. Contact is the page for a custom price above the published steps.
Multi-Engine Monitoring
Google isn't the only search engine. For comprehensive SEO monitoring, track Bing and regional engines too:
SEARCH_ENGINES = {
'google': {
'url': 'https://www.google.com/search',
'params': lambda kw, n: {'q': kw, 'num': n, 'hl': 'en'},
'result_selector': 'div.g',
},
'bing': {
'url': 'https://www.bing.com/search',
'params': lambda kw, n: {'q': kw, 'count': n},
'result_selector': 'li.b_algo',
},
}
def multi_engine_rank(keyword, target_domain, engines=None, country="us"):
"""Check rankings across engines. UK is gb. Americas use us.proxylabs.app."""
if engines is None:
engines = ["google", "bing"]
code = "gb" if country.lower() == "uk" else country.lower()
host = "us.proxylabs.app" if code in {"us", "ca", "mx", "br", "ar", "co", "cl", "pe"} else "eu.proxylabs.app"
proxy = {
"http": f"http://{PROXY_USER}-country-{code}:{PROXY_PASS}@{host}:8080",
"https": f"http://{PROXY_USER}-country-{code}:{PROXY_PASS}@{host}:8080",
}
rankings = {}
for engine_name in engines:
engine = SEARCH_ENGINES[engine_name]
try:
r = requests.get(
engine['url'],
params=engine['params'](keyword, 20),
headers=HEADERS,
proxies=proxy,
timeout=15,
)
soup = BeautifulSoup(r.text, 'html.parser')
results = soup.select(engine['result_selector'])
rank = -1
for i, result in enumerate(results, start=1):
link = result.select_one('a')
if link and target_domain in link.get('href', ''):
rank = i
break
rankings[engine_name] = rank
except Exception as e:
rankings[engine_name] = None
time.sleep(random.uniform(3, 6))
return rankings
For more on scraping strategies and avoiding blocks, see our scraping without getting blocked guide and general scraping use case page.