2016-09-14 107 views
0

我试图提取在谷歌地图上搜索公司名称时显示的详细信息。如下面的图所示:谷歌地图API提取公司详细信息

Google maps search results

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

+0

你有什么输入?地址?公司名称? –

+1

对于R你可以试试[googleway包](https://github.com/SymbolixAU/googleway)。 – Jaap

回答

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"