How to scrape location coordinates (latitude,longitude) from Google Maps?

This article explains how the Keyword Scraping feature of WebHarvy can be used to scrape coordinates (latitude and longitude) of a list of addresses from Google Maps.

Suppose the following is the list of addresses which we have. Note that these address strings do not have commas within them. It is recommended to have them this way. In case you wish to have commas within each address string then each address line should be enclosed within quotes.

6657 PEDEN RD FT WORTH TX
17425 DALLAS PKWY DALLAS TX
12121 COIT RD DALLAS TX
9100 WATERFORD CENTRE BLVD AUSTIN TX
13223 CHAMPIONS CENTRE DR HOUSTON TX
1221 N WATSON RD ARLINGTON TX
5313 CARNABY ST IRVING TX

To scrape the coordinates of these addresses automatically, first load the following URL within WebHarvy’s configuration browser.

https://www.google.com/maps/place/6657 PEDEN RD FT WORTH TX

Note that the first address (6657 PEDEN RD FT WORTH TX) is used ‘as-it-is’ in the above URL. Once this URL is loaded in the browser, Start Configuration. Now, you will have to edit the Start URL of the configuration. The Start URL in the configuration will be different since the page will have redirected to the location result page in Google. Set it again to the same Start URL which we initially loaded.

Now we can add keywords to the configuration. Keywords in this case are the list of addresses. It is important to note here that the first keyword in the list which we add, should be same as the one used in the Start URL. We have already made this sure. Since we are selecting only a single row of data from each page, we can also disable pattern detection.

The latitude/longitude values are selected from the entire page HTML using regular expressions. To get the entire page HTML double click on the Capture HTML toolbar button.

The regular expression strings used to get latitude and longitude values are given below.

www\.google\.com%2Fmaps%2F[\s\S]?%2F%40([^%])

www\.google\.com%2Fmaps%2F[\s\S]?%2F%40[^%]%2C([^%]*)

If you are new to WebHarvy we recommended that you download and try using the free evaluation version available in our website. To get started please follow the link below.

Getting started with web scraping using WebHarvy

In case you have any questions please feel free to contact our technical support team.