需要通过R访问Google自定义搜索API

需要通过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")

,我收到以下错误消息:

and I get the following error:

函数错误(类型,msg,asError = TRUE):SSL证书 问题:无法获得本地发行者证书

Error in function (type, msg, asError = TRUE) : SSL certificate problem: unable to get local issuer certificate

尽管当我在浏览器中执行获取请求时,我能够在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))