...

How to extract phone numbers from Google Maps

How to extract phone Numbers from Google Maps

Google Maps contains detailed information about a registered location, including its address, reviews, website, and phone number. However, for lead generation, we only need phone numbers, as they can be used to create potential connections with clients or customers and can be easily extracted using Serpdog’s Google Maps Scraper

Extracting Phone Numbers From Google Maps 

Extracting Phone numbers from Google Maps is simple. However, first, we need to register on serpdog.io to get an API Key.

After successfully signing up, you will be redirected to the dashboard where you will get your API Key.

Serpdog Dashboard

Then, navigate to the Google Maps API Documentation Page and scroll down to get the readymade code for creating an API request.

Documentation Code

For this tutorial, we will be using Python as a general language to create an API request. However, you can select any of the languages you are comfortable with.

In the query part, you can search for any general business category such as grocery shops, restaurants, sports, etc. For this tutorial, I will be using “coffee” as the search query which will return me to the nearest cafes for the specified latitudes and longitudes in the API parameters. The current latitudes and longitudes target the area near Lower Manhattan in New York. You can also target your location’s latitudes and longitudes.

Also, don’t forget to replace the APIKEY with the actual API key you got on registration.

Finally, we will create a CSV file and store the required information with phone numbers side-by-side.

import requests
import csv

payload = {'api_key': 'APIKEY', 'q': 'coffee', 'll': '@40.7455096,-74.0083012,15.1z'}
resp = requests.get('https://api.serpdog.io/maps_search', params=payload)
print(resp.text)

data = resp.json()

with open('phone_numbers.csv', 'w', newline='') as csvfile:
    csv_writer = csv.writer(csvfile)
    
    # Write the headers
    csv_writer.writerow(["name", "address", "website", "phone"])
    
    # Write the data
    for result in data["search_results"]:
        try:
            website = result["website"]
        except KeyError:
            website = ""  
        try:
            phone = result["phone"]
        except KeyError:
            phone = "" 
        
        csv_writer.writerow([result["title"], result["address"], website, phone])

print('Done writing to CSV file.')

We have also used the try blocks to prevent any missing key errors in the JSON response.

Run this code in the terminal and there you go!

Why use it?

Here are some reasons why this tool can be beneficial for your business:

Lead Generation — It can be a game-changer tool in building a phone number list for an outreach marketing campaign to connect with potential customers and clients.

Fast and Efficient — Automation with a collection of a large list of phone numbers and precise information makes this tool fast and efficient for businesses.

Economical — This tool is much more economical than any other trusted provider in the market including GMapExtractor, SerpAPI, Octoparse, and BrightData.

Conclusion

Phone numbers allow for direct communication with potential clients, resulting in a higher engagement rate compared to other means of communication, such as emails or messaging on social media platforms. Moreover, phone conversations often result in immediate feedback, saving you time and resources in driving customers through the sales process.

In this article, we learned to collect phone numbers from Google Maps. 

Feel free to message me anything you need clarification on. Follow me on Twitter. Thanks for reading!