【问题标题】:Intermittent Http Error 403 When Invoking Google Custom Search API调用 Google 自定义搜索 API 时出现间歇性 Http 错误 403
【发布时间】:2015-02-27 00:55:35
【问题描述】:

从服务器端设置调用自定义搜索 api 时,我间歇性地收到以下错误:

请求https://www.googleapis.com/customsearch/v1?q=John+Doe+john%40simpler.com&alt=json&cx=&key= 时的 HttpError 403 返回“您的 API 密钥上配置了 per-IP 或 per-Referer 限制,并且请求与这些限制不匹配。请使用 Google Developers Console 更新您的 API 密钥配置是否应允许来自此 IP 或引用者的请求。

我正在使用服务器 api 密钥,并已确认配置的服务器 ip 地址是正确的。大约 50% 的时间我的请求也能正常返回。我从服务器发出请求是这样的:

service = build("customsearch", "v1",
                developerKey=api_key)

custom_search_context = <my_context>

res = service.cse().list(
    q=search_query_string,
    cx=custom_search_context,
).execute()

我每秒的请求数在 10/秒的配置限制和每天 5000 个请求的购买限制内。

我注意到的另一件事是,Google 也将被禁止的请求计入每日限制。

关于为什么我只是间歇性地出现错误的任何指示都会非常有帮助

【问题讨论】:

    标签: google-api


    【解决方案1】:

    当您超过请求/秒限制时,可能会引发错误。您能否确认您的请求速率低于您配置的用户速率限制?值得注意的是,即使您没有在请求中明确提供用户值,也会强制执行该限制。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-24
      相关资源
      最近更新 更多