Last Updated : 23 Jul, 2025
In this article, we will discuss how to scrape data like Names, Ratings, Descriptions, Reviews, addresses, Contact numbers, etc. from google maps using Python.
Modules needed:For obtaining the title of the place:
review_titles=browser.find_element_by_class_name("x3AX1-LfntMc-header-title-title")
print(review_titles.text)
For obtaining the rating of the place:
stars=browser.find_element_by_class_name("aMPvhf-fI6EEc-KVuj8d")
print("The stars of restaurant are:",stars.text)
For obtaining the description of the place:
description=browser.find_element_by_class_name("uxOu9-sTGRBb-T3yXSc")
print(description.text)
For obtaining the address of the place:
address=browser.find_elements_by_class_name("CsEnBe")[0]
print("Address: ",address.text)
For obtaining the contact number of the place:
phone = browser.find_elements_by_class_name("CsEnBe")[-2]
print("Contact Number: ", phone.text)
For obtaining the reviews of the place:
Example 1:review=browser.find_elements_by_class_name("OXD3gb")
print("------------------------ Reviews --------------------")
for j in review:
print(j.text)
Scrap Title and rating.
Python3
# Import the library Selenium
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
# Make browser open in background
options = webdriver.ChromeOptions()
options.add_argument('headless')
# Create the webdriver object
browser = webdriver.Chrome(
executable_path="C:\chromedriver_win32\chromedriver.exe",
options=options)
# Obtain the Google Map URL
url = ["https://www.google.com/maps/place/%5C
Papa+John's+Pizza/@40.7936551,-74.0124687,17z/data=!3m1!4b1!\
4m5!3m4!1s0x89c2580eaa74451b:0x15d743e4f841e5ed!8m2!3d40.\
7936551!4d-74.0124687", "https://www.google.com/maps/place/%5C
Lucky+Dhaba/@30.653792,76.8165233,17z/data=!3m1!4b1!4m5!3m4!\
1s0x390feb3e3de1a031:0x862036ab85567f75!8m2!3d30.653792!4d76.818712"]
# Initialize variables and declare it 0
i = 0
# Create a loop for obtaining data from URLs
for i in range(len(url)):
# Open the Google Map URL
browser.get(url[i])
# Obtain the title of that place
title = browser.find_element_by_class_name(
"x3AX1-LfntMc-header-title-title")
print(i+1, "-", title.text)
# Obtain the ratings of that place
stars = browser.find_element_by_class_name("aMPvhf-fI6EEc-KVuj8d")
print("The stars of restaurant are:", stars.text)
print("\n")
Output:
1 - Papa Johns Pizza The stars of restaurant are: 3.6 2 - Lucky Da Dhaba The stars of restaurant are: 3.8Example 2:
Scrap Title and address.
Python3
# Import the library Selenium
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
# Make browser open in background
options = webdriver.ChromeOptions()
options.add_argument('headless')
# Create the webdriver object
browser = webdriver.Chrome(
executable_path="C:\chromedriver_win32\chromedriver.exe",
options=options)
# Obtain the Google Map URL
url = ["https://www.google.com/maps/place/%5C
Papa+John's+Pizza/@40.7936551,-74.0124687,17z/data=!3m1!4b1!\
4m5!3m4!1s0x89c2580eaa74451b:0x15d743e4f841e5ed!8m2!3d40.\
7936551!4d-74.0124687", "https://www.google.com/maps/place/%5C
Lucky+Dhaba/@30.653792,76.8165233,17z/data=!3m1!4b1!4m5!3m4!\
1s0x390feb3e3de1a031:0x862036ab85567f75!8m2!3d30.653792!4d76.818712"]
# Initialize variables and declare it 0
i = 0
# Create a loop for obtaining data from URLs
for i in range(len(url)):
# Open the Google Map URL
browser.get(url[i])
# Obtain the title of that place
title = browser.find_element_by_class_name(
"x3AX1-LfntMc-header-title-title")
print(i+1, "-", title.text)
# Obtain the address of that place
address = browser.find_elements_by_class_name("CsEnBe")[0]
print("Address: ", address.text)
print("\n")
Output:
Example 3:1 - Papa Johns Pizza
Address: 6602 Bergenline Ave, West New York, NJ 07093, United States
2 - Lucky Da Dhaba
Address: shop no.2, Patiala Road, National Highway 64, Zirakpur, Punjab 140603
Scrap Title and contact number.
Python3
# Import the library Selenium
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
# Make browser open in background
options = webdriver.ChromeOptions()
options.add_argument('headless')
# Create the webdriver object
browser = webdriver.Chrome(
executable_path="C:\chromedriver_win32\chromedriver.exe",
options=options)
# Obtain the Google Map URL
url = ["https://www.google.com/maps/place/%5C
Papa+John's+Pizza/@40.7936551,-74.0124687,17z/data=!3m1!4b1!\
4m5!3m4!1s0x89c2580eaa74451b:0x15d743e4f841e5ed!8m2!3d40.\
7936551!4d-74.0124687", "https://www.google.com/maps/place/%5C
Lucky+Dhaba/@30.653792,76.8165233,17z/data=!3m1!4b1!4m5!3m4!\
1s0x390feb3e3de1a031:0x862036ab85567f75!8m2!3d30.653792!4d76.818712"]
# Initialize variables and declare it 0
i = 0
# Create a loop for obtaining data from URLs
for i in range(len(url)):
# Open the Google Map URL
browser.get(url[i])
# Obtain the title of that place
title = browser.find_element_by_class_name(
"x3AX1-LfntMc-header-title-title")
print(i+1, "-", title.text)
# Obtain the contact number of that place
phone = browser.find_elements_by_class_name("CsEnBe")[-2]
print("Contact Number: ", phone.text)
print("\n")
Output:
1 - Papa Johns Pizza Contact Number: +1 201-662-7272 2 - Lucky Da Dhaba Contact Number: 095922 67185Example 4:
Scrap Title and reviews.
Python3
# Import the library Selenium
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
# Make browser open in background
options = webdriver.ChromeOptions()
options.add_argument('headless')
# Create the webdriver object
browser = webdriver.Chrome(
executable_path="C:\chromedriver_win32\chromedriver.exe",
options=options)
# Obtain the Google Map URL
url = ["https://www.google.com/maps/place/%5C
Papa+John's+Pizza/@40.7936551,-74.0124687,17z/data=!3m1!4b1!\
4m5!3m4!1s0x89c2580eaa74451b:0x15d743e4f841e5ed!8m2!3d40.\
7936551!4d-74.0124687", "https://www.google.com/maps/place/%5C
Lucky+Dhaba/@30.653792,76.8165233,17z/data=!3m1!4b1!4m5!3m4!\
1s0x390feb3e3de1a031:0x862036ab85567f75!8m2!3d30.653792!4d76.818712"]
# Initialize variables and declare it 0
i = 0
# Create a loop for obtaining data from URLs
for i in range(len(url)):
# Open the Google Map URL
browser.get(url[i])
# Obtain the title of that place
title = browser.find_element_by_class_name(
"x3AX1-LfntMc-header-title-title")
print(i+1, "-", title.text)
# Obtain the reviews of that place
review = browser.find_elements_by_class_name("OXD3gb")
print("------------------------ Reviews --------------------")
for j in review:
print(j.text)
print("\n")
Output:
Code Implementation: Python31 - Papa Johns Pizza
------------------------ Reviews --------------------
"The food is so good and they even make the pizza so fast, omg."
"He deals with the money also helps making the pizza without plastic gloves."
"This is my pizza place to go, no hassles at all!"
2 - Lucky Da Dhaba
------------------------ Reviews --------------------
"Best place for a small group of people, food quality is amazing"
"Nice staff and quick service good quantity and well cooked meal."
"I ordered chicken biryani they served me chicken pulao not Biryani."
# Import the library Selenium
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
# Make browser open in background
options = webdriver.ChromeOptions()
options.add_argument('headless')
# Create the webdriver object
browser = webdriver.Chrome(
executable_path="C:\chromedriver_win32\chromedriver.exe",
options=options)
# Obtain the Google Map URL
url = ["https://www.google.com/maps/place/%5C
Papa+John's+Pizza/@40.7936551,-74.0124687,17z/data=!3m1!4b1!\
4m5!3m4!1s0x89c2580eaa74451b:0x15d743e4f841e5ed!8m2!3d40.\
7936551!4d-74.0124687", "https://www.google.com/maps/place/%5C
Lucky+Dhaba/@30.653792,76.8165233,17z/data=!3m1!4b1!4m5!3m4!\
1s0x390feb3e3de1a031:0x862036ab85567f75!8m2!3d30.653792!4d76.818712"]
# Initialize variables and declare it 0
i = 0
# Create a loop for obtaining data from URLs
for i in range(len(url)):
# Open the Google Map URL
browser.get(url[i])
# Obtain the title of that place
title = browser.find_element_by_class_name(
"x3AX1-LfntMc-header-title-title")
print(i+1, "-", title.text)
# Obtain the ratings of that place
stars = browser.find_element_by_class_name("aMPvhf-fI6EEc-KVuj8d")
print("The stars of restaurant are:", stars.text)
# Obtain the description of that place
description = browser.find_element_by_class_name("uxOu9-sTGRBb-T3yXSc")
print("Description: ", description.text)
# Obtain the address of that place
address = browser.find_elements_by_class_name("CsEnBe")[0]
print("Address: ", address.text)
# Obtain the contact number of that place
phone = browser.find_elements_by_class_name("CsEnBe")[-2]
print("Contact Number: ", phone.text)
# Obtain the reviews of that place
review = browser.find_elements_by_class_name("OXD3gb")
print("------------------------ Reviews --------------------")
for j in review:
print(j.text)
print("\n")
Output:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4