Python 3.x 如何限制来自Webhos数据源的结果 def运行查询(搜索词): """ 给定包含搜索词(查询)的字符串,返回Webhose API中的结果列表, 每个结果由标题、链接和摘要组成。 """ webhose\u api\u key=read\u webhose\u key() 如果不是webhose\u api\u密钥: raise KeyError('未找到Web软管密钥') 尝试: search\u term=search\u term.strip() webhoseio.config(token=webhose\u api\u key) 查询参数={q:“{search\u term}\”是\u first:true language:english domain\u秩:

Python 3.x 如何限制来自Webhos数据源的结果 def运行查询(搜索词): """ 给定包含搜索词(查询)的字符串,返回Webhose API中的结果列表, 每个结果由标题、链接和摘要组成。 """ webhose\u api\u key=read\u webhose\u key() 如果不是webhose\u api\u密钥: raise KeyError('未找到Web软管密钥') 尝试: search\u term=search\u term.strip() webhoseio.config(token=webhose\u api\u key) 查询参数={q:“{search\u term}\”是\u first:true language:english domain\u秩:,python-3.x,webhose,Python 3.x,Webhose,您可以使用分页。 这来自webhose文档 从 仅适用于相关性排序顺序的分页参数 &from=100 def run_query(search_term): """ Given a string containing search terms (query), returns a list of results from the Webhose API, with each result consisting of a title, link and summary. """ webhos

您可以使用分页。 这来自webhose文档

仅适用于相关性排序顺序的分页参数

&from=100

def run_query(search_term):
"""
Given a string containing search terms (query), returns a list of   results from the Webhose API,
with each result consisting of a title, link and summary.
"""
webhose_api_key = read_webhose_key()

if not webhose_api_key:
    raise KeyError('webhose key not found')

try:
    search_term = search_term.strip()
    webhoseio.config(token=webhose_api_key)
    query_params = {"q": "\"{search_term}\" is_first:true language:english domain_rank:<100".format(search_term=search_term), "sort": "relevancy" }
    output = webhoseio.query("filterWebContent", query_params)

    results = []

    for post in output['posts']:
        results.append({'title': post['title'],
                        'link': post['url'],
                        'summary': post['text'][:200]})

except:
    print("Error when querying the Webhose API")

return results