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