【问题标题】:Google custom search how to set number of returned results谷歌自定义搜索如何设置返回结果的数量
【发布时间】:2013-09-03 05:57:29
【问题描述】:

我正在使用谷歌自定义搜索 API 搜索网站并尝试通过将 num 参数设置为某个高数 999 来返回最大可能的结果,但这会向我发送错误:

(400) Invalid Value

但是当我将num 的值设置为10 或更低时,它可以完美运行,所以谷歌似乎对返回的结果设置了一些限制。

Here is my Google CSE link you can check by setting the num param

Google CSE API 文档在这里:API Docs

有什么想法吗?

【问题讨论】:

    标签: google-custom-search


    【解决方案1】:

    您最多可以检索 10 个页面和最多 10 个结果。 在查询中,您可以使用 'num' 和 'start' 参数来引导您的请求。

    num = 1-10 显示多少个结果 start = 1-100 起点

    因此,如果您需要最大结果,则必须使用 num = 10(默认)和 start = 1, 11, 21, ... 91 执行 10 个请求

    【讨论】:

    • 我无法理解反对意见,但我可以确认我的答案。示例(需要您的 cx 和密钥):curl 'https://www.googleapis.com/customsearch/v1?q=super+goofy&cx=0...8&alt=json&key=A...k&start=1&num=11' 不起作用,因为您一次不能询问超过 10 个结果。 curl 'https://www.googleapis.com/customsearch/v1?q=super+goofy&cx=0...8&alt=json&key=A...k&start=100&num=2' 不起作用,因为 G 不会给出超过 100 个结果。 curl 'https://www.googleapis.com/customsearch/v1?q=super+goofy&cx=0...8&alt=json&key=A...k&start=1&num=10' 这个工作:)
    【解决方案2】:
    "queries": {
      "nextPage": [
       {
        "title": "Google Custom Search - WTB rolex",
        "totalResults": "3030",
        "searchTerms": "WTB rolex",
        "count": 10,
        "startIndex": 11,
    

    我认为他们希望您浏览结果集。所以,在这个查询中,有 3030 个结果,我们在第 1 页。

    您可以使用以下参数来指定您想要的页面:

    "start": integer
    

    它可以工作,虽然我也从中得到随机的 400 个(对我来说超过 100 400 个)。

    【讨论】:

    • 我最好的猜测是这些是免费帐户的帐户限制。如果您为服务付费,它会改变吗?
    • :( 翻阅结果.. 那是我想避免或想降低循环迭代,并且我没有付费帐户。
    猜你喜欢
    • 1970-01-01
    • 2018-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-06
    • 1970-01-01
    • 2019-09-03
    相关资源
    最近更新 更多