【问题标题】:Google custom search api - Limit results to 1 per domainGoogle 自定义搜索 api - 每个域的结果限制为 1 个
【发布时间】:2015-05-15 18:51:33
【问题描述】:

有没有办法将 Google 自定义搜索 API 返回的结果限制为每个域 1 个?

【问题讨论】:

    标签: google-custom-search


    【解决方案1】:

    是的。如果您正在寻找第一个结果。那么熟悉Python的可以试试下面的方法。

    res = service.cse().list(query,cx='YOURSEARCHENGINEIDHERE,).execute()
    
    name = res['items'][0]['title']     #title of the first search result
    url = res['items'][0]['link']       #url of the first search result
    

    【讨论】:

    • 您正在做的是从响应中获取每个域的第一个结果,即如果有 10 个结果,您将从其中获取 7 个唯一域结果(如果 3 个重复)。我正在寻找的是来自 google api 本身的 10 个独特结果。如果我对您的回答的理解不正确,请纠正我。
    • @GunmeetSingh 你找到方法了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多