This is a fork from https://github.com/omkarcloud/google-maps-reviews-scraper with small customizations:
- simplify it to keep only Google reviews context
- adapt it to poetry
- adapt it to get params from configuration
- add some functionalities in Makefile
- fix style and ensure it with pre-commits
To use the tool, you must have Node.js 16+ (https://nodejs.org/) and Python installed on your PC.
Let's get started by following these super simple steps:
1️⃣ Install Dependencies:
make install
2️⃣ Get the results by running:
make run
Remember to add your params in params.yaml
file.
3️⃣ Clean repo:
make clean
4️⃣ Clean repo and results:
make clean_all
5️⃣ Run pre-commits:
make pre-commit
Once the scraping process is complete, you will find the search results in the output
directory.
Exception: Unable to consent Cookies
is raised. Try again with a lower max
param.
Open the main.py
file, and update the queries
list with your desired(s) query.
queries = ["web developers in delhi"]
Gmaps.places(queries, max=5)
A: Remove the max
parameter.
By doing so, you can scrape all the Google Maps Listing. For example, to scrape all web developers in Bangalore, modify the code as follows:
queries = ["web developers in bangalore"]
Gmaps.places(queries)
You can scrape a maximum of 120 results per search, as Google does not display any more search results beyond that. However, don't worry about running out of results as there are thousands of cities in our world :).
You can apply filters such as:
min_reviews
/max_reviews
(e.g., 10)category_in
(e.g., "Dental Clinic", "Dental Laboratory")has_website
(e.g., True/False)has_phone
(e.g., True/False)min_rating
/max_rating
(e.g., 3.5)
For instance, to scrape listings with at least 5 reviews and no more than 100 reviews, with a phone number but no website:
Gmaps.places(queries, min_reviews=5, max_reviews=100, has_phone=True, has_website=False)
To scrape listings that belong to specific categories:
Gmaps.places(queries, category_in=[Gmaps.Category.DentalClinic, Gmaps.Category.DentalLaboratory])
See the list of all supported categories here
We sort the listings using a really good sorting order, which is as follows:
- Reviews [Businesses with more reviews come first]
- Website [Businesses more open to technology come first]
- LinkedIn [Businesses that are easier to contact come first]
- Is Spending On Ads [Businesses already investing in ads are more likely to invest in your product, so they appear first.]
However, you also have the freedom to sort them according to your preferences as follows:
-
To sort by reviews:
Gmaps.places(queries, sort=[Gmaps.SORT_BY_REVIEWS_DESCENDING])
-
To sort by rating:
Gmaps.places(queries, sort=[Gmaps.SORT_BY_RATING_DESCENDING])
-
To sort first by reviews and then by those without a website:
Gmaps.places(queries, sort=[Gmaps.SORT_BY_REVIEWS_DESCENDING, Gmaps.SORT_BY_NOT_HAS_WEBSITE])
-
To sort by name (alphabetically):
Gmaps.places(queries, sort=[Gmaps.SORT_BY_NAME_ASCENDING])
-
To sort by a different field, such as category, in ascending order:
Gmaps.places(queries, sort=[[Gmaps.Fields.CATEGORIES, Gmaps.SORT_ASCENDING]])
-
Or, to sort in descending order:
Gmaps.places(queries, sort=[[Gmaps.Fields.CATEGORIES, Gmaps.SORT_DESCENDING]])
Having read this page, you have all the knowledge needed to effectively utilize the tool.
You may choose to explore the following questions based on your interests:
- I Don't Have Python, or I'm Facing Errors When Setting Up the Scraper on My PC. How to Solve It?
- How to Scrape Reviews?
- What Are Popular Snippets for Data Scientists?
- How to Change the Language of Output?
- I Have Google Map Places Links, How to Scrape Links?
- How to Scrape at Particular Coordinates and Zoom Level?
- When Setting the Lang Attribute to Hindi/Japanese/Chinese, the Characters Are in English Instead of the Specified Language. How to Transform Characters to the Specified Language?