Separate Pending Tasks from Empty Google Search Results
说明与用途
Python脚本对保存的Scrapeless Google Search API响应进行分类,区分待处理任务、HTTP错误和格式错误,并输出具有明确状态和空有机结果计数的质量记录,直到获得有效数组为止。
问题
When using the Scrapeless Google Search API, empty result lists can be misinterpreted as successful searches, obscuring pending tasks, failures, or malformed data.
结果
The classifier reliably distinguishes pending tasks, HTTP errors, and malformed responses from genuine empty organic result sets, enabling accurate dashboards and error handling.
工作流
- 1. Save the API capture JSON (includes request, http_status, response, run_id, received_at).
- 2. Run the provided Python script:
python3 capture_state.py capture.json. - 3. The script parses the capture, checks http_status and response structure, and assigns a state: transport_error, pending, http_error, unmapped, or completed.
- 4. It extracts taskId if present and sets organic_count to None until a valid organic_results array is found.
- 5. Output the derived record as JSON to stdout for downstream processing.
证据
The quickstart describes HTTP 200 as task data and HTTP 201 as a pending task.
The output uses organic_count=null until a completed, structurally valid organic array is available.
- 记录日期: 2026-09-20T00:00:29.321Z