Need to access Google Custom Search api via R

How to use R to do a custom Google search? I have a search engine id and api key. I am currently trying to do this:

getURL("https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=ENGINE_ID&q=searchterm") 

and I get the following error:

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

Although I can get the results in json when I get the request in the browser. Any clue on what's going on?

+5
source share
2 answers

httr package works!

 library(httr) query="https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=ENGINE_ID&q=SEARCH_TERM" content(GET(query)) 
+4
source

set ssl.verifypeer=TRUE to getURL

 getURL("https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=ENGINE_ID&q=searchterm", ssl.verifypeer=TRUE) 
+3
source

All Articles