Need to access Google Custom search api through R

久未见 提交于 2019-12-23 10:33:07

问题


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:

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

Though I am able to get the results in json when I do a get request in the browser. Any clue on whats happening?


回答1:


httr package worked!!

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



回答2:


set ssl.verifypeer=TRUE in getURL

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


来源:https://stackoverflow.com/questions/30246787/need-to-access-google-custom-search-api-through-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!