Back to blog
Guides & How-tos2026-03-15·11 min read

Google Maps Python Selenium Guide: Extract Data

By Ibrahim DemolCEO IBLeadUpdated March 15, 2026

Do you want to extract data from Google Maps using Python and Selenium? This guide covers everything: setting up the environment, writing the script, and pitfalls to avoid. The keyword google maps python selenium extract often appears in searches by developers looking to automate local data collection — and for good reason. Google Maps contains millions of business listings with addresses, phone numbers, ratings, and hours. All this information is useful for prospecting, market research, or competitive analysis.


Why combine Python and Selenium to scrape Google Maps?

Python is the go-to language for web scraping. Its syntax is clear, its community is massive, and its libraries cover all needs: data manipulation with Pandas, HTTP requests with Requests, HTML parsing with BeautifulSoup.

However, Google Maps presents a specific problem. A large portion of the data is not in static HTML. Information displays after user interactions: clicking on a listing, scrolling through the list, opening a sidebar. A simple requests.get() is not enough.

This is where Selenium comes in. Selenium drives a real browser (Chrome, Firefox, Edge) and simulates the behavior of a real user. It can click, scroll, wait for an element to appear, and extract dynamically rendered content. Combined with Python, it becomes a robust tool for automating data extraction on complex web interfaces like Google Maps.


Setting up the development environment

Before writing any code, you need to install the right tools.

1. Install Python

Download the latest stable version of Python from python.org. When installing on Windows, make sure to check the "Add Python to PATH" option — without it, the pip commands won't work in the terminal.

Check the installation with:

python --version

2. Install Selenium

Open your terminal or command prompt and type:

pip install selenium

Selenium installs in a few seconds. You will also need Pandas to organize the data:

pip install pandas

3. Download the WebDriver

Selenium needs a WebDriver to control your browser. The WebDriver is an executable that links your Python script to the browser.

The version of the WebDriver must exactly match the version of your browser. Check your Chrome version in chrome://settings/help and download the corresponding ChromeDriver.

Since Selenium 4.6+, you can also use selenium-manager which manages the download automatically. Handy to avoid version errors.


Understanding the structure of Google Maps before scraping

Before writing the script, take 5 minutes to inspect Google Maps in your browser's developer tools (F12).

Here’s what you will observe:

  • The list of results is in a scrollable container with a specific CSS class
  • Each business listing is a clickable element
  • The details (phone, website, hours) only appear after clicking on a listing
  • Google Maps loads results with lazy loading — the elements at the bottom of the list do not exist in the DOM until you scroll down

These dynamic behaviors explain why Selenium is necessary. They also explain why scraping Google Maps is technically more complex than a static site.

Note: Google Maps limits results to 120 listings per search. If your geographic area contains more than 120 businesses in a category, you will need to break your search down (by district, postal code, etc.) to cover the entire area.


Writing the Python Selenium script for Google Maps

Here’s a functional example that searches for restaurants in a city and extracts their addresses.

Script structure

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
import time
import pandas as pd

# Launch the Chrome browser
driver = webdriver.Chrome()
driver.get("https://www.google.com/maps")

# Wait for the page to load
time.sleep(3)

# Enter the search query
search_bar = driver.find_element(By.NAME, "q")
search_bar.send_keys("Restaurants Paris 11")
search_bar.send_keys(Keys.ENTER)

# Wait for the results
time.sleep(5)

# Scroll through the list to load more results
results_panel = driver.find_element(By.CSS_SELECTOR, "div[role='feed']")
for _ in range(5):
    driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", results_panel)
    time.sleep(2)

# Extract the listings
results = driver.find_elements(By.CSS_SELECTOR, "div.Nv2PK")
addresses = []

for result in results:
    try:
        name = result.find_element(By.CSS_SELECTOR, ".qBF1Pd").text
        address_elements = result.find_elements(By.CSS_SELECTOR, ".W4Efsd span")
        address = " ".join([el.text for el in address_elements if el.text])
        addresses.append({"Name": name, "Address": address})
    except Exception:
        pass

# Export to CSV
df = pd.DataFrame(addresses)
df.to_csv("restaurants_paris.csv", index=False, encoding="utf-8-sig")
print(f"{len(addresses)} restaurants extracted.")

# Close the browser
driver.quit()

What this script does, step by step

Step 1 — Launch Chrome: webdriver.Chrome() opens a Chrome window controlled by Selenium. You will see it open on your screen.

Step 2 — Navigate to Google Maps: driver.get() loads the page. The time.sleep(3) allows time for the JavaScript to execute.

Step 3 — Start the search: The script finds the search bar by its name="q" attribute, types the query, and presses Enter.

Step 4 — Scroll: The loop scrolls the results panel 5 times to trigger lazy loading and load more listings.

Step 5 — Extract: For each found listing, the script retrieves the name and address. The try/except block prevents the script from crashing if an element is missing.

Step 6 — Export: Pandas organizes the data into a DataFrame and saves it as CSV. The utf-8-sig encoding ensures that special characters (accents, etc.) display correctly in Excel.


Extracting additional data: phone, website, rating

To retrieve the phone number, website, and Google rating, you need to click on each listing and wait for the detail panel to open.

for result in results:
    try:
        result.click()
        time.sleep(3)  # Wait for the detail panel
        
        # Google rating
        try:
            rating = driver.find_element(By.CSS_SELECTOR, "span.MW4etd").text
        except:
            rating = ""
        
        # Phone
        try:
            phone = driver.find_element(
                By.CSS_SELECTOR, 
                "button[data-item-id^='phone'] span.Io6YTe"
            ).text
        except:
            phone = ""
        
        # Website
        try:
            website = driver.find_element(
                By.CSS_SELECTOR, 
                "a[data-item-id='authority']"
            ).get_attribute("href")
        except:
            website = ""
            
        addresses.append({
            "Name": name,
            "Phone": phone,
            "Website": website,
            "Rating": rating
        })
        
    except Exception:
        pass

This code is slower. Each click + wait takes 3 to 5 seconds. For 100 listings, expect 5 to 8 minutes of execution time minimum.


Google Maps CSS selectors break regularly

This is the number one problem with scraping Google Maps using Selenium. Google changes its CSS classes without warning. A script that works today may return zero results tomorrow.

Some best practices to limit breakage:

Use stable attributes: The data-item-id, aria-label, and role attributes change less frequently than automatically generated CSS classes.

Add logs: Display the number of elements found at each step. If a selector returns 0 results, you will know immediately.

Version your script: Keep old versions. When Google breaks your selectors, you can compare and identify what has changed.

Test with driver.page_source: Save the HTML of the page to inspect it offline when something doesn’t work.


Handling restrictions and CAPTCHAs

Google detects automated behaviors. Here are the signals that trigger blocks:

  • Too many requests from the same IP in a short time
  • No delay between actions (non-human behavior)
  • Missing or generic user-agent
  • Absence of session cookies

Strategies to reduce blocks

Add random delays: Replace time.sleep(3) with time.sleep(random.uniform(2, 5)). Fixed delays are more easily detected.

Use a real Chrome profile: Launch Chrome with your existing user profile to benefit from your cookies and history.

options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=/path/to/your/chrome/profile")
driver = webdriver.Chrome(options=options)

Use a proxy or VPN: If your IP is blocked, a rotating proxy or VPN allows you to change your IP address. Services like Bright Data or Oxylabs offer residential proxies suitable for scraping.

Limit the volume per session: Don’t scrape 500 listings in a row. Break it down into sessions of 50-100 listings with breaks in between.


The 120 results limit on Google Maps

Google Maps never returns more than 120 results per search, regardless of the geographic area. This is a structural constraint, not a bug.

To bypass this limit and cover an entire city:

  1. Break it down by district or neighborhood: "Restaurants Paris 1er", "Restaurants Paris 2ème", etc.
  2. Break it down by postal code: Iterate over a list of postal codes.
  3. Use a geographic grid: Divide the area into cells and run a search per cell.

This approach multiplies the number of requests and thus the execution time. To cover a large city with several categories, expect several hours of scraping.


Going further with BeautifulSoup and Requests

Selenium is not always necessary. For some data accessible in static HTML, BeautifulSoup and Requests are sufficient and much faster.

pip install beautifulsoup4 requests

But for Google Maps specifically, the dynamic rendering makes Selenium essential for most data. BeautifulSoup is more useful for scraping business websites once you have retrieved their URLs from Google Maps — for example, to extract contact emails.


When manual scraping becomes counterproductive

Writing and maintaining a Google Maps scraper takes time. A lot of time.

  • Initial setup: 2 to 4 hours for an experienced developer
  • Maintenance when Google changes its selectors: 1 to 3 hours per incident
  • Managing proxies and CAPTCHAs: variable monthly cost
  • Execution time for large volumes: several hours per export

For a developer wanting to learn web scraping, it’s an excellent exercise. For a sales team that needs 10,000 qualified contacts quickly, it’s a waste of time.

IBLead is a direct alternative. The database contains 50M+ Google Maps businesses in 37 countries, already indexed and updated weekly. You filter by city, category, Google rating, number of reviews, technologies used on the website — and export to CSV in 2 minutes. No code, no WebDriver, no CAPTCHA. At €44 for 10,000 leads, that’s €0.004 per contact.

If you need local data for prospecting and not a technical scraping project, IBLead saves you several hours.


FAQ

Google's terms of service prohibit automated scraping of its services. In practice, Google can block your IP or account. Legally, the situation varies by country and the use of the data. For large-scale commercial use, consult a lawyer specializing in digital law.

Why does my Selenium script no longer find elements?

Google Maps regularly updates its CSS classes. Open the developer tools (F12), inspect the elements you are looking for, and update your CSS selectors. This is the number one cause of scripts that stop working.

How to extract emails from Google Maps?

Google Maps does not display emails directly. To retrieve them, you first need to extract the URLs of the business websites, then scrape those sites to find email addresses in the "Contact" pages or in the footer. IBLead does this work upstream: emails are enriched from the websites and included in each export.

Google Maps limits results to 120 listings per search. To cover a larger area, you need to multiply requests by breaking down by neighborhood, postal code, or using a geographic grid.

Selenium or Playwright for scraping Google Maps?

Both work. Playwright (by Microsoft) is newer and often faster. It handles asynchronous waits better and is less detected as a bot. If you are starting a new scraping project, Playwright is worth exploring. Selenium remains more documented and has a larger community.


Conclusion

The Python + Selenium duo allows for automated data extraction from Google Maps. It’s a useful skill for any developer working on data collection or web automation projects. Setting it up requires diligence: managing delays, maintaining selectors, circumventing restrictions.

If your goal is commercial prospecting rather than technical learning, IBLead gives you access to the same data without writing a line of code. Try it with 200 credits.

free credits — 200 credits included

Ready to get started?

Access every Google Maps business, enriched with emails and legal data.

Try IBLead free