DEV Community

Cover image for Track Location-Based Rankings in New York, London, and Beyond with Python Automation
Carllowman
Carllowman

Posted on

Track Location-Based Rankings in New York, London, and Beyond with Python Automation

Local SEO often requires seeing results as users in different locations do. I needed to check how my site ranks in New York vs London, so I used the SERPSpur Local Search Spoofing Tool to simulate searches by city. Here's a Python script to automate that:

python
import requests

API_KEY = "your_api_key_here"

def spoof_local_search(query, city, country):
url = "https://serpspur.com/tool/local-search-spoofing-tool/"
params = {
"q": query,
"city": city,
"country": country,
"api_key": API_KEY
}
response = requests.get(url, params=params)
data = response.json()
results = data.get("organic_results", [])
for i, r in enumerate(results[:5], 1):
print(f"{i}. {r['title']} - {r['link']}")

Example

spoof_local_search("coffee shops", "New York", "US")

This revealed different rankings for the same query across locations. It's a handy way to tune local SEO strategies. Have you noticed location-based ranking differences in your niche?

Top comments (2)

Collapse
 
burhanchaudhry profile image
Burhan

I've seen similar shifts for service-based businesses—what surprised me most was how even a 5-mile radius changed rankings for 'plumber near me.' Do you adjust your on-page content by city or rely more on local citations?

Collapse
 
emma-watson3 profile image
Emma Watson

That local spoofing feature is a lifesaver for multi-location businesses. I noticed huge ranking variations for service-based keywords between cities, especially with Google's localized results. Do you adjust your content strategy per location based on these tests?