DEV Community

Cover image for How To Scrape Data from Google Maps with Octoparse
Antonello Zanini for Writech

Posted on • Updated on • Originally published at writech.run

How To Scrape Data from Google Maps with Octoparse

Scraping data from web pages can quickly become a time-consuming and difficult task. Follow this link if you want to learn more about web scraping.

Luckily, tools to make this easier and avoid all the well-known challenges that come with scraping have been developed in recent years. Particularly, Octoparse is one of the best and smartest solutions on the market.

Octoparse is a no-code web scraping software that gives you the power to easily and automatically detect and extract data from any website — such as Google Maps. Since no code is involved in the scraping process, this tool is open to anyone. Plus, it allows you to execute scraping tasks on-demand by using its official APIs as described here. And starting with the 8.4.2 version, you can also auto-export your cloud data with Zapier to Google Drive, Google Sheets, and other similar services.

Let's see now see how to configure Octoparse to scrape data from Google Maps, store it in the cloud, and then use Zapier to export it into a Google Sheets document.

What Is Octoparse?

"Octoparse provides data scraping services based on a point-and-click interface anyone can use to scrape data from any dynamic website" Octoparse official website

Octoparse is a professional website crawler you can use to extract multiple types of data from the web. In detail, it comes with features to make scraping a trivial activity. For example, you can configure it to follow the links and keep extracting data while browsing a website, automatically rotate the user agent string, and deal with pagination or infinite scrolling — even when confined to a specific part of the page. These are just a limited set of all the features Octoparse comes with. You can find them all here.

Moreover, it supports both a simple and an advanced mode. The first one is based on an advanced auto-detection algorithm that makes data extraction easy and automatic, and it is meant for users with basic needs. On the other hand, the second one allows users with customized needs to unleash the true power of the tool. What they both share is the user-friendly point-and-click interface devised by Octoparse to guide you throughout the entire process of data discovery, selection, and extraction.

Wrapping up, Octoparse is an easy-to-use no-code service allowing you to scrape data of any format while dealing with several websites, no matter their structure. Pagination and infinite scrolling are no obstacles, as well as different date formats, and anti-scraping techniques. In fact, Octoparse comes with IP proxy servers you can use to hide your IP and rotate it to avoid IP blocking. And when you have finally extracted your data, you can save it locally and backup it to the cloud with a couple of clicks. All this without requiring any coding skills.

Scraping Data From Google Maps

Let's now use Octoparse to scrape data from the New York restaurants page on Google Maps. Considering how Google Maps works, scraping it would be complex. In fact, it shows the most important data in an isolated section while implementing both pagination and infinite scrolling.

The Google Maps interaction

Fortunately, as you are about to see, Octoparse makes everything easier.

First, you will see how to install Octoparse. Then, you will learn how to define a scraping task aimed at extracting data from the section of the Google Maps page shown in the GIF above.

1. Getting started with Octoparse

It is time to install Octoparse. To perform the scraping task on Google Maps, you will require Octoparse 8.4.2 or higher. You can download it here: https://www.octoparse.com/download.

Then, follow the next few steps:

  1. Run the Octoparse Setup 8.4.2.exe file

  2. Follow the installation instructions

  3. Log in with your Octoparse account, or sign up here if you do not have an account yet.

Signing up is free, but some advanced feasters may require the Standard, Professional, or Enterprise plan. You can find all the information on the plans offered by Octoparse here.

You are now ready to see Octoparse in action!

2. Defining the Scraping Task

Since the goal here is to extract data from Google Maps, following the official guide on how to scrape Google Maps pages is recommended.

Run Octoparse, perform the login, and paste the following target URL into the main input field:

https://www.google.com/maps/search/google+maps+restaurant+new+york/@40.7725863,-74.0380563,12z?hl=en
Enter fullscreen mode Exit fullscreen mode

Entering the input URL

Now, click "Start" to launch the Octoparse scraping interface. Since the results are spread throughout many pages, you need to create a pagination loop. To achieve this, follow these three steps:

  1. Click on the ">" Google Maps button at the end of the left section

  2. Select "Loop click Single image" on the "Tips" panel

  3. Set up a 15s AJAX Timeout for the "Click to Paginate" action

Setting up the pagination loop

Now, it is time to create a scrolling loop. This is required to retrieve all the data from the current page before moving on to the next one in the pagination loop. You can set it up by performing the following operations:

  1. Within the "Pagination Action" action, click the "+" ("Add a step") button

  2. Select the "Loop" option and make sure to add the blank action before the "Pagination1" action

  3. Select the first and the second restaurant sections on the left side of the page

  4. Click "Loop click each URL" on the "Tips" panel

  5. In the "Options" tab, uncheck the "Open in a new tab" option

  6. Set the "AJAX Timeout before the next step" to 5s

Completing the scrolling loop

Now, click on the "Auto-detect webpage data" button in the "Tips" panel to let Octoparse automatically extract the information shown int the restaurant leaf page. Then, select the data you are interested in.

Extracting Title, Image, Reviews, and Type information from the restaurant page

Then, click on "Create workflow" and finalize the scraping process.

Your scraping task has just been set up, and you are now able to launch it with the "Run" button. Be sure to select the "Run in the cloud option" in the popup "Run Task" window.

The popup

The task will now be performed automatically on the cloud. This will also give you the possibility to run the task programmatically by using the Octoparse API explained here.

From Octoparse to Google Sheets with Zapier

Octoparse is now supported by Zapier. This means you can use Zapier to store the data extracted with your aforementioned scraping task into a Google Sheets file. This can be easily be achieved by following the step-by-step wizard process defined by Zapier here.

The Zapier step-by-step wizard

By performing each operation required by the procedure, you will be able to see your scraped data retrieved by the task executed in the cloud in a Google Sheets document as follows:

The Google Sheets document generated by Zapier with the data extracted by Octoparse

Conclusion

Here we looked at how what Octoparse is and how to use this flexible data extraction tool to extract data from Google Maps. Then, we learned how it can be integrated with Zapier to automatically store the extracted data in a Google Sheets document. Without Octoparse this would be a challenging task to accomplish. Thankfully, this no-code tool is a powerful service, allowing anyone to scrape the web with just a few clicks. This is particularly useful when dealing with complex websites adopting infinite scrolling and implementing anti-scraping measurements — such as Google Maps.

Thanks for reading! I hope that you found this article helpful.


The post "How To Scrape Data from Google Maps with Octoparse" appeared first on Writech.

Top comments (0)