This Python script fetches data from the Google Places API based on specified search parameters and saves the results to an Excel file.
The script retrieves information about places near a specified location using the Google Places API. It allows customization of search parameters such as radius, keyword, type, and language. The fetched data is then parsed and saved to an Excel file.
- Python 3.x
- pandas
- requests
-
Clone this repository to your local machine:
git clone <repository-url>
-
Install the required Python packages:
pip install pandas requests
-
Obtain a Google Places API key from the Google Cloud Console and replace the
API_KEY
variable in the script with your own API key.
-
Open the script in a Python environment.
-
Customize the search parameters as needed:
latitude
andlongitude
: The coordinates of the city or location.radius
: The search radius in meters.keyword
: A term to be matched against all content that Google has indexed for a place.type
: Restricts the results to places matching the specified type.language
: The language code, indicating in which language the results should be returned.
-
Run the script. The fetched data will be saved to an Excel file named
city_amenities.xlsx
.
This Python script fetches data from the Google Places API based on specified search parameters and saves the results to an Excel file. This is an enhanced version of the original script with multithreading capability for improved performance.
The script retrieves information about places near a specified location using the Google Places API. It allows customization of search parameters such as radius, keyword, type, and language. The fetched data is then parsed and saved to an Excel file. In this version, multithreading with ThreadPoolExecutor is utilized to fetch data for multiple coordinates concurrently, leading to faster execution.
- Python 3.x
- pandas
- requests
-
Clone this repository to your local machine:
git clone <repository-url>
-
Install the required Python packages:
pip install pandas requests
-
Obtain a Google Places API key from the Google Cloud Console and replace the
API_KEY
variable in the script with your own API key. -
Ensure your coordinates are stored in an Excel file with columns for latitude and longitude. Update the
excel_file
variable in the script with the path to your Excel file.
-
Open the script in a Python environment.
-
Customize the search parameters as needed:
radius
: The search radius in meters.keyword
: A term to be matched against all content that Google has indexed for a place.type
: Restricts the results to places matching the specified type.language
: The language code, indicating in which language the results should be returned.
-
Run the script. The fetched data will be saved to an Excel file.
In version 2 of the script, multithreading with ThreadPoolExecutor is used to fetch data for multiple coordinates concurrently, enhancing performance by utilizing parallel processing.
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests.