需要通过 R 访问 Google 自定义搜索 api
问题描述:
如何使用 R 进行 Google 自定义搜索?我有自定义搜索引擎 ID 和 api 密钥.我目前尝试这样做:
How do I use R to do a Google Custom search? I have the custom search engine id and the api key. I currently try to do this:
getURL("https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=ENGINE_ID&q=searchterm")
我收到以下错误:
函数错误(类型、味精、asError = TRUE):SSL 证书问题:无法获得本地颁发者证书
Error in function (type, msg, asError = TRUE) : SSL certificate problem: unable to get local issuer certificate
虽然我可以在浏览器中执行 get 请求时以 json 格式获取结果.关于发生了什么的任何线索?
Though I am able to get the results in json when I do a get request in the browser. Any clue on whats happening?
答
httr 包有效!!
library(httr)
query="https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=ENGINE_ID&q=SEARCH_TERM"
content(GET(query))