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 摘要。