Google Maps Scraper with Python and Selenium: Complete Guide
Do you need to extract the contact details of 500 restaurants, the emails of local plumbers, or customer reviews from a region? Google Maps contains this data, but downloading it manually takes hours.
This is where Python and Selenium come into play. These two tools allow you to automate data extraction from Google Maps — but they require time, programming skills, and pose significant technical challenges.
This article shows you how Python and Selenium work for scraping, the concrete steps to get started, the pitfalls to avoid, and most importantly: when a manual approach is not the right solution.
Why Python and Selenium for Google Maps?
Google Maps is not a simple static HTML page. Results load dynamically: you type a search, listings gradually appear, you scroll, and more results load. This is JavaScript in action.
Three tools can extract this data:
1. BeautifulSoup or Requests These Python libraries retrieve the raw HTML code of a page. Problem: they cannot execute JavaScript. On Google Maps, you get a blank page.
2. Selenium Selenium launches a real browser (Chrome, Firefox) and simulates clicks, scrolls, and human interactions. JavaScript executes. You can wait for the results to load and then extract them. It’s slow, but it works.
3. Puppeteer or Playwright Tools similar to Selenium, faster, but less documented for beginners.
Why choose Python + Selenium? - Python is easy to learn and well-documented - Selenium works with all browsers - Combined, they handle dynamic pages without an API - You have full control over what you extract
Key limitation: it’s slow. Extracting 1,000 results can take 2-3 hours. And you risk IP blocks, CAPTCHAs, or temporary bans.
Technical prerequisites: what to install
Before writing a single line of code, install these tools.
1. Python (version 3.8 or later)
Download from python.org. During installation, check "Add Python to PATH" — this is crucial for using Python from the command line.
Check the installation:
python --version
You should see Python 3.x.x.
2. Selenium
Open your terminal or command prompt and type:
pip install selenium
Pip (Python Package Manager) automatically downloads and installs Selenium.
3. WebDriver for your browser
Selenium cannot control a browser without a driver (WebDriver). The most common choice is Chrome.
For Chrome:
- Download ChromeDriver (must match your version of Chrome)
- Unzip the file
- Note the full path of the chromedriver file (e.g., /Users/name/Downloads/chromedriver)
Simple alternative: install webdriver-manager to avoid managing versions manually:
pip install webdriver-manager
4. Additional libraries
To process and export data:
pip install pandas requests beautifulsoup4
- Pandas: organizes data into tables (DataFrames)
- Requests: makes HTTP requests (optional here, but useful)
- BeautifulSoup: parses HTML (optional)
Check that everything works:
python -c "import selenium; print(selenium.__version__)"
You should see a version number (e.g., 4.15.2).
Anatomy of a Selenium script for Google Maps
Here’s the general structure of a Google Maps scraping script:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
import time
import pandas as pd
# 1. Launch the browser
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
# 2. Access Google Maps
driver.get("https://www.google.com/maps")
# 3. Search for a term
search_box = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "searchboxinput"))
)
search_box.send_keys("Restaurants Paris")
search_box.send_keys(Keys.ENTER)
# 4. Wait for results
time.sleep(3)
# 5. Extract data
results = []
result_elements = driver.find_elements(By.CLASS_NAME, "Nv2PK")
for element in result_elements:
try:
name = element.find_element(By.CLASS_NAME, "NrjWb").text
results.append({"name": name})
except:
pass
# 6. Export to CSV
df = pd.DataFrame(results)
df.to_csv("restaurants.csv", index=False)
# 7. Close the browser
driver.quit()
Let’s break down each step.
Step 1: Launch the browser
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
webdriver-manager automatically downloads the correct version of ChromeDriver. You don’t need to do anything manually.
Alternative without webdriver-manager (if you downloaded ChromeDriver manually):
driver = webdriver.Chrome("/path/to/chromedriver")
Step 2: Access Google Maps and search
driver.get("https://www.google.com/maps")
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Wait for the search bar to be visible
search_box = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "searchboxinput"))
)
# Type the search
search_box.send_keys("Plumbers Lyon")
# Press Enter
from selenium.webdriver.common.keys import Keys
search_box.send_keys(Keys.ENTER)
# Wait for the results to load
time.sleep(3)
Why WebDriverWait?
Google Maps loads elements dynamically. If you try to find the search bar before it exists, the script crashes. WebDriverWait waits up to 10 seconds for the element to appear.
Step 3: Extract names and addresses
# Find all results (each result is a business listing)
result_elements = driver.find_elements(By.CLASS_NAME, "Nv2PK")
results = []
for element in result_elements:
try:
# Business name
name = element.find_element(By.CLASS_NAME, "NrjWb").text
# Address
address = element.find_element(By.CLASS_NAME, "Xs85Hc").text
# Rating (optional)
try:
rating = element.find_element(By.CLASS_NAME, "MW4etd").text
except:
rating = "N/A"
results.append({
"name": name,
"address": address,
"rating": rating
})
except Exception as e:
print(f"Error: {e}")
continue
print(f"Extracted {len(results)} results")
CSS selectors: By.CLASS_NAME finds elements by their CSS class. Class names (Nv2PK, NrjWb) change regularly on Google. If the script doesn’t work, open the inspector (F12) and find the correct classes.
Step 4: Handle pagination
Google Maps displays about 20 results per page. To get more, you need to scroll down the list.
# Find the results container
results_container = driver.find_element(By.CLASS_NAME, "m6QErb")
# Scroll 5 times (each scroll loads ~20 additional results)
for _ in range(5):
driver.execute_script(
"arguments[0].scrollTop = arguments[0].scrollHeight",
results_container
)
time.sleep(2) # Wait for results to load
# Extract ALL results (now that you have scrolled)
all_results = driver.find_elements(By.CLASS_NAME, "Nv2PK")
Warning: scrolling 5 times = ~100 results. Scrolling 20 times = 400+ results and 2-3 minutes. It’s slow.
Step 5: Extract coordinates (latitude/longitude)
Google Maps stores GPS coordinates in the URL. You can retrieve them by clicking on a listing.
results = []
for element in result_elements:
try:
name = element.find_element(By.CLASS_NAME, "NrjWb").text
# Click on the result to open the detailed listing
element.click()
time.sleep(1)
# Get the URL (it contains the coordinates)
current_url = driver.current_url
# Format: https://www.google.com/maps/place/.../@48.8566,2.3522,...
results.append({
"name": name,
"url": current_url
})
except Exception as e:
print(f"Error: {e}")
The coordinates are in the URL after /@ (latitude, longitude).
Step 6: Export data to CSV
import pandas as pd
# Convert to DataFrame
df = pd.DataFrame(results)
# Export to CSV
df.to_csv("google_maps_results.csv", index=False, encoding="utf-8")
print(f"✓ {len(results)} results exported to google_maps_results.csv")
Open the CSV file in Excel or Google Sheets.
Step 7: Close the browser
driver.quit()
Always close the browser to free up memory.
Complete script: concrete example
Here’s a working script to extract restaurants from a city:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
import time
import pandas as pd
# Launch the browser
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
try:
# Access Google Maps
driver.get("https://www.google.com/maps")
# Search for restaurants
search_box = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "searchboxinput"))
)
search_box.send_keys("Restaurants Marseille")
search_box.send_keys(Keys.ENTER)
time.sleep(3)
# Scroll to load more results
results_container = driver.find_element(By.CLASS_NAME, "m6QErb")
for _ in range(3):
driver.execute_script(
"arguments[0].scrollTop = arguments[0].scrollHeight",
results_container
)
time.sleep(2)
# Extract data
results = []
result_elements = driver.find_elements(By.CLASS_NAME, "Nv2PK")
for element in result_elements[:50]: # Limit to 50 for testing
try:
name = element.find_element(By.CLASS_NAME, "NrjWb").text
address = element.find_element(By.CLASS_NAME, "Xs85Hc").text
results.append({
"name": name,
"address": address
})
except:
pass
# Export
df = pd.DataFrame(results)
df.to_csv("restaurants_marseille.csv", index=False, encoding="utf-8")
print(f"✓ {len(results)} restaurants extracted")
finally:
driver.quit()
Run it:
python scraper.py
A Chrome browser opens, performs the search, and exports the results.
The real challenges of scraping Google Maps
The script works on your computer. But at scale, you encounter problems.
1. IP Blocking
After 50-100 requests from the same IP, Google temporarily blocks you. You see a CAPTCHA or an error page.
Solutions:
- Add random delays between requests (time.sleep(random.randint(2, 5)))
- Use proxies or a VPN
- Spread requests over several days
2. CAPTCHA
Google may display a CAPTCHA to verify that you are human. Selenium cannot solve it automatically (without paid external tools).
Solutions: - Accept that some requests will fail - Use CAPTCHA solving services (expensive and slow) - Scrape in moderation
3. Changing CSS Selectors
Google regularly changes its CSS classes. Nv2PK today may become Abc123 tomorrow. Your script breaks.
Solutions: - Use more stable XPath selectors (more complex) - Check and update the script every month - Monitor for errors
4. Performance
Extracting 1,000 results = 50+ minutes. Extracting 10,000 = 8+ hours. It’s very slow compared to automated tools.
5. Incomplete Data
You get names and addresses. But emails, phone numbers, reviews, technologies used? You need to click on each listing, wait for it to load, then extract. It’s even slower.
6. Legal Compliance
Google Maps ToS prohibit automated scraping. You’re unlikely to face lawsuits, but your account may be banned, or your IP permanently blocked.
When Python + Selenium is NOT the right solution
Selenium is powerful, but it’s not the ideal tool for:
Extracting > 500 results regularly Too slow, too many risks of blocking.
Getting emails, phones, reviews, technologies Selenium can do it, but you would need to click on each listing. 1,000 listings = 2-3 days of scraping.
Data that needs to be updated monthly You will have to rerun the script every month. Risk of blocking with each run.
Need for enriched data Raw data from Google Maps lacks business information.
No coding skills Python + Selenium require debugging, maintenance, and updates.
IBLead: the no-code alternative
If you need to quickly extract data from Google Maps without scraping, there’s another approach: using a pre-indexed database.
IBLead is a database of 50M+ Google Maps businesses (France, Belgium, Switzerland, Canada, the United States, and 10+ other countries). The data is updated monthly — no need to scrape.
You can search by city, region, category, and then export to CSV with: - Names, addresses, phones - Emails (enriched from the website) - Google reviews (full text, ratings, dates, authors) — exclusive - Detected technologies (WordPress, Shopify, HubSpot, etc.) — exclusive - Social media, hours, GPS coordinates
Comparison: Python + Selenium vs IBLead
Ready to get started?
Access every Google Maps business, enriched with emails and legal data.
Try IBLead freeRelated articles
10 Proven Tips to Get Customers to Leave More Google Reviews on Maps
Learn 10 actionable strategies to increase Google Maps reviews. Timing, incentives, QR codes, and response tactics that actually work.
7 Cold Email Mistakes to Avoid: Examples & Templates
Avoid these 7 cold email mistakes to avoid examples that kill response rates. Real examples, AIDA templates, and proven fixes for better outreach.
ABM Google Maps Data: The Complete Strategic Guide
Learn how abc account based marketing google maps data drives 208% more revenue. Build precise target lists with 50M+ pre-indexed businesses.