Scraper API: send waitFor as an object, read the target status from http_code - #4
Merged
Merged
Conversation
…ttp_code
Measured 2026-09-23 against scraper.2captcha.com/tasks/sync:
- waitFor as a JSON-encoded string -> HTTP 422 "params.waitFor must be an
object", still billed $0.0005; as an object -> HTTP 200. _build_wait_for
now returns a dict.
- The response's `status` is the API's own verdict ("success"); the target's
status is `http_code`. fetch_html now reads http_code (fallback to status
only if it is an int), so a target 403 reaches detect_page_state.
Regression check check_scraper_api_waitfor_is_object_and_status_is_http_code
drives the real fetch_html with requests.post stubbed. Control: with the
old client restored the suite goes red on both of its messages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two defects in
scraper_api_client.py, both measured 2026-09-23 againsthttps://scraper.2captcha.com/tasks/sync.1.
waitForwas sent as a JSON-encoded string. The live API now answers that with HTTP 422ScrapeParser: params.waitFor must be an object— and still bills the task ($0.0005). The same request withwaitForas an object is answered 200._build_wait_fornow returns a dict (Optional[dict]), logged viajson.dumps; its docstring, which said the string form was required, now records the measurement instead.2. The target site's status was never read. The response is
{"status": "success", "http_code": <int>, "headers": …, "body": …}. The client readstatus— the API's own verdict string — sodetect_page_stategot"success"instead of the target's 403/503, and this repo's "Wellfound refused the Scraper API's exit" branch could not fire on a status. It now readshttp_code, falling back tostatusonly if that is an int.Check
check_scraper_api_waitfor_is_object_and_status_is_http_codeinsmoke_test.py(auto-discoveredcheck_function, defined before theCHECKSlist is built) drives the realfetch_htmlwithrequests.poststubbed to capture the payload and return{"status":"success","http_code":403,…}, and asserts (a)waitForis a dict for--wait-text, (b) the status handed onward is403(int).Control: a copy of this branch with
scraper_api_client.pyrestored fromorigin/main(asserted that the file actually changed) → suite exit 1, both of the new check's messages FAILED (got '{"text": "Python"}'andgot 'success'). Real branch → exit 0, 365 checks passed.Live (one call, key via env)
scraper_api_client.py --url https://wellfound.com/role/r/software-engineer --wait-state load --retries 0→ API HTTP 200 (no 422),Upstream page status (http_code) 200, 567146 bytes, 38 jobs parsed, exit 0.Worth noting: the module docstring says (measured 2026-09-17) that Wellfound answers the Scraper API's datacentre exits with 403. On this one call on 2026-09-23 it served the page. One call is not enough to rewrite that measurement, so the docstring is left as it is; it deserves a re-measure.
Not changed
[Unreleased].🤖 Generated with Claude Code