Sometimes the data you want to scrape from a website might be inside a map.
A common scenario would involve scraping data from a Google Maps with multiple store locations.
Today, we will go over how to use a free web scraper to extract data from an interactive map.
In this case, we will scrape a store locator Google Maps for addresses, phone numbers and emails.
A Free and Powerful Web Scraper
For this project, we will use ParseHub a free and powerful web scraping that can work with any website. Make sure to download and install ParseHub for free before getting started.
We will also scrape data from Long & Mcquade’s Ontario store locator page.
How to Scrape Data from a Locations Map
Now it’s time to get scraping.
Keep in mind that every map looks different. The one you are dealing with might look different than the one we are scraping from. However, this guide should cover the general
- Install and open ParseHub. Click on “New Project” and enter the URL you will be scraping data from. In this case, we are scraping data from the Ontario store locator on the Long & Mcquade website. Once submitted, the URL will render inside the app and a “Select” command will be created by default.
- Start by clicking on any of the “location pins” on the map. This will create a new selection on the left sidebar, rename your selection to “location”. Now click on a second pin on the map to select them all.
- Click on the PLUS (+) sign next to your “location” selection, click on Advanced and choose the “Begin New Entry” command. Rename this command to “map”.
- Use the icon next to the “extract name” command to delete it.
- Click on the PLUS (+) sign next to your “map” command and choose the “Click” command. A pop-up will appear asking you if this a next page button. Click on “No” and choose “Continue executing the current template”
- Click on the PLUS (+) sign next to your “map” selection and choose the “select” command. Use this command to click on the location name that appears on top of the location pin on the map. You might have to press Ctrl+2 on your keyboard to select the location name instead of the entire div. Rename your selection to “location_name”
- Click on the PLUS (+) sign next to your “location_name” selection and add an “extract” command. This will extract the name of each location.
- Let’s also extract the phone number of each location. To do this, Hold shift over your “location_name” selection to make its PLUS (+) sign appear, click it and add a Relative Select command. Using the Relative Select command, click on the name of the location and then on its phone number. Again, you might have to use the Ctrl+2 keys to select the phone number instead of the whole div. An arrow will appear to indicate the relationship you are creating.
ParseHub is now extracting the location name and phone number for each location.
Extracting Store Addresses and Emails from a Map
On this map, each location has a link to view more store info. We will now tell ParseHub to click on these links and extract each store’s address and email address.
- Click on the PLUS (+) sign next to your “map” command and choose the select command. Then click on the “View Store Details” link on the map to select it. Rename your selection to “store_details”
- Click on the PLUS (+) sign next to your “store_details” selection and choose the “Click” command.
- A pop-up will appear asking you if this is a “next page” link. Click on “No” and create a new template named “store_page”.
- The Store Details page will render inside the app and a new select command will be created in your new commands template. Use this command to select the address of the business. Rename your selection to “address1”
- This website codes the address of each business in two parts. We will click on the PLUS (+) sign next to the page selection and add another Select command to extract the second part of the address. Rename this to “address 2”.
- Lastly, repeat the previous step to add another Select command and click on the email address for the store. Rename your selection to “email”. You can repeat this step to extract any other additional info from this page.
Running your Scrape
It is now time to run your scrape an extract all the data you have selected for all the locations on the map.
Click on the green “Get Data” button on the left sidebar. Here you will be able to test, run or schedule your scrape job.
In this case we will run it right away. ParseHub will now go and collect all the data you have selected.
Closing Thoughts
Once ParseHub is done extracting the data you have selected, you will be able to download it as an Excel or JSON file.
You now know how to extract data from an interactive map or store locator.
If you have any questions about this project, reach out to us via the live chat on our website and we will be happy to assist you.
Happy scraping!