Make `async: True` batch searches work out of the box

未关闭
#53 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
api

调研方向

Start by reading the implementations of Client.search and Client.search_archive, then check the README examples. Decide whether the contribution will add a helper that submits, polls, and re-queues searches or document that workflow. Done means bulk async searches can be handled with less setup, and archive polling does not reuse the initial search parameters such as q.

由索引模型根据 Issue 内容生成。

描述

Moved from the deprecated google-search-results-python package: https://github.com/serpapi/google-search-results-python/issues/51 (originally reported by dimitryzub).

Original request

From a user perspective, the less setup required the better. [...] The user has to just add an async: True and don't bother tinkering/figuring out stuff for another ~hour about how Queue or something else works.

Today, running async searches in bulk means submitting each search with async: True, keeping the search IDs in a queue, polling the Search Archive API, and re-queueing searches that aren't finished (status other than Cached or Success).

Applies to serpapi-python: Client.search and Client.search_archive expose the building blocks, but the queue and polling logic is left to the user and the README has no helper or example for it.

Proposal: a helper that does this under the hood. The original issue suggested an API along these lines (adapted to the new client):

import serpapi

client = serpapi.Client(api_key="...")

# hypothetical API
results = client.async_search(
    queries=["burly", "creator", "doubtful", "minecraft"],
    engine="youtube",
    device="desktop",
)

Alternatively, a documented README example of the submit, poll and re-queue loop would already help.

One thing to keep in mind from the original thread: when polling the archive, don't reuse the params from the initial search, because passing q to the Search Archive API returns an error.

主要语言
Python
星标
183
派生
28
平均合并
8 天 14 小时
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

serpapi/serpapi-python 的其他 Issue

查看 serpapi/serpapi-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。