nodejs-automation

1.0.2 • Public • Published

Google Places Search and Export to Excel

This Node.js package allows you to search for places using the Google Maps Places API and export the search results to an Excel file. It's useful for quickly gathering information about various places based on keywords and locations.

Features

  • Search for places using a keyword and city name.
  • Retrieve detailed information such as name, address, rating, reviews, and phone number for the top 20 results.
  • Export the search results to an Excel file for easy reporting and sharing.
  • Handles API rate-limiting with delays between requests.

Installation

To use this package, you need to have Node.js installed. You can then install the package via npm:

npm i nodejs-automation

Prerequisites

You need a valid Google Maps API Key to use the Google Maps Places API. Set up your API key in a .env file.

Create a .env file in the root of your project with the following content:

GOOGLE_MAPS_API_KEY=your_google_maps_api_key

Replace your_google_maps_api_key with your actual API key.

Usage

Programmatic Usage

You can use the package in your code like this:

const main = require('nodejs-automation');

const keyword = 'restaurants';
const city = 'New York';

main(keyword, city);

Output

The search results will be saved as an Excel file named <keyword>_in_<city>.xlsx in the current directory.

For example, if you search for restaurants in New York, the file will be named restaurants_in_new_york.xlsx.

API Details

The package uses the following Google Maps APIs:

  • Text Search API: To search for places based on a keyword and location.
  • Place Details API: To fetch detailed information about each place.

Error Handling

  • If no results are found for a search, the script will attempt a broader search.
  • Any API errors or issues are logged to the console.

Rate Limiting

To avoid exceeding API rate limits, the script adds a 1-second delay between requests for place details.

Example Output

Example data for a search result:

Name Address Description Rating Reviews Phone
Example Restaurant 123 Main St, New York, NY OPERATIONAL 4.5 120 +1-234-567-8900

How to Contribute

Contributions are welcome! Feel free to open an issue or submit a pull request with improvements or bug fixes.

License

This package is licensed under the MIT License.

Support

If you encounter any issues or have questions, feel free to open an issue on the GitHub repository.

Disclaimer

This package uses the Google Maps API, and you are responsible for any associated costs or compliance with the Google Maps Platform Terms of Service.

Readme

Keywords

none

Package Sidebar

Install

npm i nodejs-automation

Weekly Downloads

6

Version

1.0.2

License

ISC

Unpacked Size

7.21 kB

Total Files

3

Last publish

Collaborators

  • akshay7903