Scrape address and phone numbers data from Google Maps
Retrieving data for a handful of entities is very straightforward. However, if you have to do hundreds, thousands or even more, it becomes a challenge that must be addressed. In this article, I will show how you can retrieve hundreds of business addresses and phone data in minutes using SerpApi’s Google Maps API.
We've done the tedious task to scrape Google Maps data, making it easier for you to access by simply calling an API. Most importantly, it works at scale. If you'd like an overview of Google Maps, feel free to check out another article of ours - Google Maps Scraper.
Code - Javascript
It is very simple to integrate with SerpApi. Before writing any code, head over to SerpApi and get your API key. After registering for a new account, you will receive 100 free searches every month.
Install SerpApi package (integration guide):
npm install serpapi
Make Request to SerpApi's Google Maps API:
The package provides a helper method to interact with our API. For our current task, we will use google_maps
engine and the q
(search queries) will be the name of each museum. Check the documentation for a full list of parameters and examples.
const json = await getJson({
api_key: "<Replace with your API KEY>",
engine: "google_maps",
q: museum,
hl: "en",
type: "search",
})
Full code:
Wrap the request in a loop to get the address and phone data for each museum.
const museums = [
"The Louvre - Paris, France",
"The British Museum - London, UK",
"The Metropolitan Museum of Art - New York, USA",
...
"The Istanbul Modern - Istanbul, Turkey",
"The Neues Museum - Berlin, Germany",
"The National Gallery of Canada - Ottawa, Canada"
]
const { getJson } = require("serpapi")
const getAddressAndPhone = async () => {
for (const museum of museums) {
const json = await getJson({
api_key: "<Replace with your API KEY>",
engine: "google_maps",
q: museum,
hl: "en",
type: "search",
})
console.log(`${museum}: ${json?.place_results?.address} (${json?.place_results?.phone})`)
}
}
getAddressAndPhone()
Output:
The Louvre - Paris, France: 75001 Paris, France (+33 1 40 20 53 17)
The British Museum - London, UK: Great Russell St, London WC1B 3DG, United Kingdom (+44 20 7323 8299)
The Metropolitan Museum of Art - New York, USA: 1000 5th Ave, New York, NY 10028 ((212) 535-7710)
...
The Istanbul Modern - Istanbul, Turkey: Kılıçali Paşa, Tophane İskele Cd. No:1/1, 34433 Beyoğlu/İstanbul, Türkiye (+90 212 334 73 00)
The Neues Museum - Berlin, Germany: Bodestraße 1-3, 10178 Berlin, Germany (+49 30 266424242)
The National Gallery of Canada - Ottawa, Canada: 380 Sussex Dr, Ottawa, ON K1N 9N4, Canada (+1 613-990-1985)
No Code - Google Sheets
We provide a convenient way to use our API inside Google Sheets. In addition, one of our team members created a No Code tool to help you collect data and export to excel from Search Engines without writing a single line of code. If you’re interested, feel free to check it out.
Similar to the code version, we will retrieve the address and phone data based on the given place name. Below are the final results you will get.
First of all, create a new blank Google sheet. At the top menu, find Extensions > Add-ons > Get add-ons. This is to install SerpApi script, enabling Google Sheets to use the formula to retrieve data from our API.
Type in "SerpApi" in the search box and you should see our script.
Click on the search results and you will find our script. Proceed to install the script.
After you have successfully installed, you should see a new row has been added to Extensions. Click on it to setup your API key (you only have to do once).
Now, let's fill in the data!
The first column is plain text, for our example, it is the name of the museum.
e.g. The Louvre - Paris, France
The second column is the address. Obviously, we will fill this in using SerpApi's Google Maps API. The formula to achieve this is as follow:
=SERPAPI_RESULT("engine=google_maps&q=" & ENCODEURL(A2) & "&hl=en&type=search", "place_results.address")
Replace A2 with the appropriate column (museum name)
The phone column is very similar to address, we only have to change the data we access, place_results.address
to place_results.phone
.
=SERPAPI_RESULT("engine=google_maps&q=" & ENCODEURL(A2) & "&hl=en&type=search", "place_results.phone")
Replicate the formula for all the museums and see the data filling in. Here is the full list of 100 museums if you want to try it out:
The Louvre - Paris, France
The British Museum - London, UK
The Metropolitan Museum of Art - New York, USA
The Vatican Museums - Vatican City
The Prado Museum - Madrid, Spain
The Hermitage Museum - St. Petersburg, Russia
The Rijksmuseum - Amsterdam, Netherlands
The National Gallery - London, UK
Museo Nacional de Antropología - Mexico City, Mexico
The Uffizi Gallery - Florence, Italy
The Guggenheim Museum - New York, USA
Tate Modern - London, UK
The Museum of Modern Art (MoMA) - New York, USA
The State Tretyakov Gallery - Moscow, Russia
The Museum of Fine Arts - Boston, USA
The Getty Center - Los Angeles, USA
Smithsonian National Museum of Natural History
National Museum of China Changan
Main National Gallery of Art
Museo Reina Sofia - Madrid, Spain
The Art Institute of Chicago - Chicago, USA
Centre Pompidou - Paris, France
The Pergamon Museum - Berlin, Germany
The Ashmolean Museum - Oxford, UK
The Royal Ontario Museum - Toronto, Canada
The National Museum of Korea - Seoul, South Korea
The National Museum of Scotland - Edinburgh, UK
The Tokyo National Museum
The Musée d'Orsay - Paris, France
The São Paulo Museum of Art - São Paulo, Brazil
The National Archaeological Museum - Athens, Greece
The Victoria and Albert Museum - London, UK
The National Palace Museum - Taipei, Taiwan
The National Gallery of Victoria - Melbourne, Australia
The Museo Nazionale Romano - Rome, Italy
Acropolis Museum
The Museum of Egyptian Antiquities - Cairo, Egypt
The Pinakothek der Moderne - Munich, Germany
The Dallas Museum of Art - Dallas, USA
The Barnes Foundation - Philadelphia, USA
The Kunsthistorisches Museum - Vienna, Austria
The Musée Rodin - Paris, France
The Van Gogh Museum - Amsterdam, Netherlands
The Altes Museum - Berlin, Germany
The Museum of Islamic Art - Doha, Qatar
The Museum of London - London, UK
The Philadelphia Museum of Art - Philadelphia, USA
The Galleria Borghese - Rome, Italy
The Palazzo Pitti - Florence, Italy
The National Museum of Natural History - Washington, D.C., USA
The National Museum of Anthropology - Manila, Philippines
The Solomon R. Guggenheim Museum - New York, USA
The National Portrait Gallery - London, UK
The Israel Museum - Jerusalem, Israel
The Musée de l'Orangerie - Paris, France
The Alte Nationalgalerie - Berlin, Germany
The Pushkin State Museum of Fine Arts - Moscow, Russia
The Musée Picasso - Paris, France
The Museum of Applied Arts - Budapest, Hungary
The Museum of Fine Arts - Houston, USA
National Museum of Ireland - Natural History
The Imperial War Museum - London, UK
The Museo Soumaya - Mexico City, Mexico
The San Francisco Museum of Modern Art - San Francisco, USA
The National Maritime Museum - Greenwich, UK
Scottish National Gallery
The Pergamon Altar Museum - Berlin, Germany
The Musée des Arts et Métiers - Paris, France
The Seattle Art Museum - Seattle, USA
The Egyptian Museum of Turin - Turin, Italy
Main Saint Louis Art Museum
The Museu Nacional d'Art de Catalunya - Barcelona, Spain
The Belvedere Palace Museum - Vienna, Austria
Museum of Contemporary Art Denver
The Freer Gallery of Art - Washington, D.C., USA
The Australian National Maritime Museum - Sydney, Australia
The Royal Museum of Fine Arts - Brussels, Belgium
The Museo de Bellas Artes - Buenos Aires, Argentina
The National Museum of the American Indian - Washington, D.C., USA
The Louisiana Museum of Modern Art - Humlebæk, Denmark
The Georgia O'Keeffe Museum - Santa Fe, USA
The Museum of Western Art - Tokyo, Japan
The Modern Art Museum of Fort Worth - Fort Worth, USA
The Asian Art Museum - San Francisco, USA
The Museum of Decorative Arts - Paris, France
The Holocaust Memorial Museum - Washington, D.C., USA
The Museum of Science and Industry - Chicago, USA
The Natural History Museum - London, UK
The Andy Warhol Museum - Pittsburgh, USA
The National Art Museum of China - Beijing, China
Main Shanghai Museum
Main Helsinki Art Museum
National Air and Space Museum
The Science Museum - London, UK
Main Museum of New Zealand Te Papa Tongarewa
The Museum of the City of New York - New York, USA
The Museo de Arte Moderno - Mexico City, Mexico
The Istanbul Modern - Istanbul, Turkey
The Neues Museum - Berlin, Germany
The National Gallery of Canada - Ottawa, Canada
Conclusion
Google Maps data scraping is a good way to extract local business data. Whether you are looking for a code or no-code way to extract data from Google Maps or other search engines, we have an easy and fast solution for you. Feel free to customize the solution to your needs and if you have any questions regarding SerpApi or web scraping in general, contact me at terry@serpapi.com. Cheers!