【问题标题】:Need to access Google Custom search api through R需要通过R访问谷歌自定义搜索api
【发布时间】:2015-05-14 20:31:27
【问题描述】:

如何使用 R 进行 Google 自定义搜索?我有自定义搜索引擎 ID 和 api 密钥。我目前正在尝试这样做:

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

我收到以下错误:

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

虽然我在浏览器中执行获取请求时能够以 json 格式获取结果。有什么线索吗?

【问题讨论】:

    标签: r api ssl google-custom-search


    【解决方案1】:

    httr 包成功了!!

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

    【讨论】:

      【解决方案2】:

      getURL中设置ssl.verifypeer=TRUE

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

      【讨论】:

      • 当我设置ssl.verifypeer" = FALSE 时它对我有用,无论如何这似乎更合乎逻辑。帮助中没有提到该参数。
      猜你喜欢
      • 1970-01-01
      • 2011-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-21
      • 2015-12-14
      • 1970-01-01
      相关资源
      最近更新 更多