Google maps API提取公司详细信息

时间:2016-09-14 09:20:23

标签: python r google-maps-api-3

我正在尝试提取您在Google地图上搜索公司名称时显示的详细信息。如下图所示:

Google maps search results

我厌倦了http://maps.google.com/maps/api/geocode/json?address=这只给出了formatted_address。但我需要从结果中获取网站和联系方式。有人可以帮助我使用什么API吗?如果代码在R或python中也会很好。

2 个答案:

答案 0 :(得分:0)

您提到的网址是Google Geocoding API,对于公司详细信息,您应该使用Google Places API中的地点方法。

答案 1 :(得分:0)

正如@Procrastinatus指出的那样,您可以使用我的googleway软件包在R中使用google_places()功能执行此操作。您需要有效的Google API密钥。

请注意,您在Google地图上看到的内容并不总是Places API返回的内容。

library(googleway)

## your valid api key
# api_key <- read.dcf("~/Documents/.googleAPI", fields = "GOOGLE_API_KEY")

search_res <- google_places(search_string = "Olympus Avenue, Warwick, UK", 
                            key = api_key)

search_res$results$name
# [1] "Holiday Inn Leamington Spa - Warwick"


search_res <- google_places(search_string = "Assured Property Group, UK", 
                            key = api_key)
search_res$results$name
# [1] "Assured Property"

search_res$results$formatted_address
# [1] "77 Market St, Droylsden, Manchester M43 6DD, United Kingdom"

geo <- google_geocode(address = "Assured Property Group, Olympus Avenue, Warwick, UK", 
                      key = api_key)

search_res <- google_places(location = c(geo$results$geometry$location$lat, 
                                         geo$results$geometry$location$lng),
                            radius = 1000,
                            key = api_key)

search_res$results$name
# [1] "Holiday Inn Leamington Spa - Warwick" "McDonald's"                          
# [3] "Pure Offices Leamington Spa"          "Canute Group"                        
# [5] "Local Taxis"                          "Timpson Locksmith's & Safe Engineers"
# [7] "mplcontact"                           "Roast Coffee Weight Loss"            
# [9] "We Buy Your Tyres"                    "Diamond Taxis"                       
# [11] "NS Line Cars"                         "Costa Coffee Drive Thru"  
相关问题