Skip to content

This web tool lets you search for business information (name, address, phone number, website, latitude, longitude) by address or phone number using the Google Maps Places API, and returns a list of businesses and information at that address or phone number.

License

Notifications You must be signed in to change notification settings

jcald1/google-map-places-to-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Maps Places: Get Business Name, Address, Phone Numbers, and Website by Searching by Addresses or Phone Number. Results are Exported to CSV

This web tool lets you search for business information (name, address, phone number, website, latitude, longitude) by address or phone number using the Google Maps Places API, and returns a list of businesses and information at that address or phone number.

Setup

  1. Go to https://developers.google.com/maps/gmp-get-started and to set up your Google account and Google Maps API Key. In the 'Getting Started' section, select the 'Maps' and 'Places' checkbox. Google requires you to set up a billing account.
  2. You can manage your account by going to https://console.cloud.google.com/google/maps-apis.
  3. Copy the generated API Key from the step above.
  4. Enable the Google Custom Search JSON API Download this Tool
    1. For Non-Developers:
      1. Click the Clone or Download button here in GitHub.
      2. Click Download Zip
      3. Extract the Zip file
      4. To be notified of new versions of the tool, click the 'Watch' icon on this page.
    2. For Developers:
      1. Clone this repo.
  5. Copy the sample-config.js file in the js directory to config.js in the same js directory.
  6. In the apiKey property, replace the text inside the single quotes with the API Key generated above.
  7. In the coordinates section, add the latitude and longitude of the map you're searching. These properties don't seem to be required. The zoom can be changed if needed. The zoom levels are in meters and are described in this page. To learn more about the options, go to the Google Maps API documentation.
  8. If searching by phone number and searching for phone numbers outside of the US, change the country code property in config.js with the two letter country code. To learn more about the phone formatter used by this tool, visit the google libphonenumber page

Running the Tool

  1. Navigate to the extracted zip folder and copy the path of the index.html file (e.g., /home/user/Downloads/google-map-places-to-csv/index.html). Paste this path into your browser's URL text box.

  2. Search by either entering in a phone number, an address, or by selecting a CSV file. The phone numbers don't have to be in any particular format as this tool uses a software library to convert it to a standard format. For addresses, enter in the full address if you have it. If not, then a partial address may be OK (just like when you enter a partial address in Google Maps)

    1. For CSV Files, note the following
      1. Look at the sample-config.js file in the js directory for an example.
      2. By default, you need either one column to contain the name address or one column to contain the name phone. These and other values can be changed in teh config file (copy sample-config.js to config.js in the same js directory and make changes as needed).
      3. You only need the address or the phone number of a place you're looking for. The results will return both the address and phone number if matches are found (plus all of the other information).
      4. Make sure that any columns with blank data still have commas. For example, for one of your rows, if the first column has a value of "abc" and the second column is blank, the row should be: abc,. Note the trailing comma. Likewise, if there are two blank cells next to each other, they should contain two commas next to each other: ,,. Excel or Libre Office should automatically set this up when exporting to CSV. Make sure that if a cell contains commas that you surround the text with double quotes: "text". If the cell contains a double quote, then you need to escape it using two double quotes: "".
      5. Addresses should be surrounded by double quotes, e.g. "123 Main St., San Francisco, CA". This prevents the commas in the addresses from messing up the CSV columns. If the address itself needs a double quote, then replace it with two double quotes next to each other, e.g. "Attn ""Mr. Rogers"", 123 Main St., San Francisco, CA"
      6. If you use a tool like Excel or Libre Office to export the CSV, make sure you pay attention to the options in the export so the rules above are followed. There should be an option to include the header (address,phone) in the CSV output.
  3. This tool does a "Search Places", "Geocode", and "Search Details" call on every address or phone number serially. Since the calls aren't going out in parallel, this means that it can take a long time for a CSV file to be processed.

  4. The maximum number of results for any given address or phone number is currently 20. Google lets you query additional results (up to 60), but this tool doesn't do that. .1. To prevent CORS errors in the browser, the easier thing to do would be to set up a local web server: set up a local web server. If this link isn't working, just search for 'test local web server'. Those instructions should tell you how to set up the web server on your system, copy in the contents of the extracted zip directory to the web server's directory of web files, start the web server, and open the tool in the browser (should be http://localhost/<some_path>).

  5. If you see an error related to CORS, change the settings on browser to get around the CORS error. This site has instructions on how to do that or just search for "fix CORS" and the name of your browser (firefox, safari, chrome, etc.). Firefox may work better than the other browsers and can be set up to work without a web server.

  6. The tool has been tested on Firefox. It might not work on other browsers without running a web server (see notes above).

  7. After entering in an address, phone number, or CSV, if the tool doesn't seem to do anything, check your console for errors. If this link doesn't work, search for 'check console' and the name of your browser (firefox, safari, chrome, etc.).

  8. If you get a OVER_QUERY_LIMIT error message on the page, try increasing the delayMilliseconds configuration value in the config.js.

  9. In the config.js, there are properties called nearbySearchStopAtFirstMatch placeSearchStopAtFirstMatch, geocodeStopAtFirstMatch, and nearbySearchStopAtFirstMatch. If these "true" and your address then the tool won't try to find additional matches for the respective Google API call. This can save you money, but you could miss out on results.

  10. The geocodeRadiusMeters property can be tweaked if needed. When the address is geocoded, the tool does a separate search to get businesses within a radius from that location. The higher the number, the more results you'll get, but it will also cost more. The number of results is also capped, so it is often better to use a smaller number to ensure that the best result(s) are returned.

  11. Lets say you search out a 20 meter radius and it comes back with 10 results. The tool is going to make a Place Details request on each one of those results, which can get expensive. If you want it to just quit once it finds the first address, keep that set to true.

    For example, in order to get both the Starbucks and the Target to come back in the search by "789 Mission St, San Francisco, CA 94103", I had to set nearbySearchStopAtFirstMatch to false and have geocodeRadiusMeters at 20. Even if two businesses are at the same exact address, Google knows when they are in slightly different physical locations (e.g., different businesses in a mall that happen to share the same address).

    To really save money, I would set geocodeRadiusMeters to 1, then you might as well leave nearbySearchStopAtFirstMatch, placeSearchStopAtFirstMatch, geocodeStopAtFirstMatch, and nearbySearchStopAtFirstMatch set to false in case another business is physically in the same exact location.The main thing is to not have to make so many Place Detail calls for every address, which happens when you use larger values for geocodeRadiusMeters.

    If you want the output CSV to have a one-to-one match with the input records, set the nearbySearchStopAtFirstMatch, placeSearchStopAtFirstMatch, geocodeStopAtFirstMatch, and nearbySearchStopAtFirstMatch` values all to "true". While the output should match one-to-one, it's possible that there are bugs in the tool and some records are dropped, so compare the input and output records to make sure there is a one-to-one match.

    There is an errorMessage column that lists specific errors that occurred for a record. These errors have to do with the data in the response (e.g., no matching address found). The tool continues on the next records in the input CSV file. You can always search for these addresses or phone numbers manually in maps.google.com to see if you can retrieve any results, or tweak the configuration settings and try again.

    If there is a networking or similar error, then the tool halts and you are able to download the results generated up to that point. You can delete part of the records from the input file that were already processed and try the rest of the records, and combine the output files once they are all finished processing.

About

This web tool lets you search for business information (name, address, phone number, website, latitude, longitude) by address or phone number using the Google Maps Places API, and returns a list of businesses and information at that address or phone number.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published