R程序获取百度地图坐标 # 加载程序包 library(rvest) library(rjson) library(stringr) # 设定url,其中百度大厦为地址 url = paste0("http://api.map.baidu.com/","geocoder/v2/?", "ak=your key&", "callback=showLocation&", "output=json&", "address=", "百度大厦", "&city=北京市") # 解析地址 address_html = html(url) address_json = address_html %>% html_nodes("p") %>% html_text() # 提取地址的json数据 address_json = str_extract(address_json, "\\(.*\\)") address_json = str_replace(address_json, "\\(", "") address_json = str_replace(address_json, "\\)", "") # 这里处理方式可以优化为一步处理 # 解析json address_json = fromJSON(address_json) print(address_json) 参考文献: 百度地图API R parse Json