A script that scrapes places from Google Maps and export the result into a JSON file.
- Python 3.11
- Selenium 4.7.2
- Webdriver Manager
- Run the
app.py
- The script will do some automation steps in the background
- Leave it running until the console says "Done"
- Check the
places.json
in the project based directory - Change the
search_text
if needed
places.json
output:
[
{
"name": "Ron Jon Surf Shop",
"stars": "4.6",
"reviews": "8,938",
"address": "4151 N Atlantic Ave",
"phoneNumber": "+1 321-799-8820"
},
{
"name": "CaliFlorida Surf & Skate Shop",
"stars": "4.7",
"reviews": "69",
"address": "5221 Ocean Blvd",
"phoneNumber": ""
}
]
This is an installation guide if you're new to Python.
1) Install virtualenv
Virtualenv is basically a tool that creates an isolated Python environment to avoid conflicting with global Python. You can use a different version of Python other than the one installed on your local machine.
Set it up by either of these ways
At base project directory, run
virtualenv venv
Install necessary modules
pip3 install -r requirements.txt
Activate the virtual environment
source venv/bin/activate
To deactivate it, run this during being "activated"
deactivate
New
/Project from Existing Sources...
- Select the repo
- In
Project Structure
/SDKs
,Add Python SDK
- Point
Location
to directoryvenv
- Point
Base intepreter
to the Python version you want to use - Click
OK
- Point
- IntelliJ will pop up and ask you to install the modules in
requirements.txt
- or you can manually do it vi
Tool
/Sync Python Requirements...
- or you can manually do it vi
- This script works in 2023-01-12
- If Google updates their HTML, I will update the script
- Feel free to create issues
- Do not focus on another Google Chrome during non-headless mode (
headless=False
)- because Selenium will be confused with the instance you're in