需要通过 R 访问 Google 自定义搜索 api [英] Need to access Google Custom search api through R

查看:40
本文介绍了需要通过 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))

这篇关于需要通过 R 访问 Google 自定义搜索 api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆