[SCR-383] Auto-Mode (--mode auto / --max-cost) support#26
Open
kostas-jakeliunas-sb wants to merge 1 commit into
Open
[SCR-383] Auto-Mode (--mode auto / --max-cost) support#26kostas-jakeliunas-sb wants to merge 1 commit into
kostas-jakeliunas-sb wants to merge 1 commit into
Conversation
Add Auto-Mode to the `scrape` command, mirroring the server-side beta feature.
The API picks the cheapest scraping config that succeeds (cheap -> expensive,
stops at first success) and charges only for the winning config.
- scrape.py: `--mode` (Choice[auto]) + `--max-cost` (int) options; signature;
pass-through to build_scrape_kwargs; validation guards (mode-auto vs
render_js/premium_proxy/stealth_proxy/transparent_status_code incompatibility,
max_cost requires mode=auto, max_cost >= 1 via _validate_range).
- cli_utils.py: build_scrape_kwargs mode/max_cost; surface Spb-auto-cost header
("Auto Credit Cost") in write_output verbose block.
- client.py: Client.scrape() mode/max_cost params (omitted when None).
- Tests: TestModeParam + TestMaxCostParam (test_client.py) and
TestModeAutoGuards command-level guard tests (test_cli.py).
- Docs: SKILL.md reference/scrape/options.md (Auto-Mode section), README,
CHANGELOG [1.4.5]; synced via sync-skills.sh.
- Version bumped 1.4.4 -> 1.4.5 across all version-bearing files.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
marius-nemeiksis-sbee
approved these changes
Jul 2, 2026
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.
tl;dr
Adds Auto-Mode to the
scrapingbee scrapecommand:--mode autolets the API pick the cheapest scraping config that succeeds and charges only for the winning config;--max-cost Ncaps the credits a request may spend. Threaded through all four layers (command → cli_utils → client → tests), mirroring the SCR-426--tagpattern. Versioned 1.4.5. Server feature is beta + flag-gated — do not merge until it ships.Summary
src/scrapingbee_cli/commands/scrape.py— new--mode(click.Choice(["auto"])) and--max-cost(int) options in the option group; added toscrape_cmdsignature; passed intobuild_scrape_kwargs(...). Three validation guards in thetry:block (matching existing guard style):--mode auto+ any of--render-js/--premium-proxy/--stealth-proxy/--transparent-status-code(presence, evenfalse) → error + exit 1 (Auto-Mode picks these itself; the server 400s the combo).--max-costwithout--mode auto→ error + exit 1.--max-cost < 1→ error via the existing_validate_rangepattern.src/scrapingbee_cli/cli_utils.py—build_scrape_kwargs()gainsmode/max_cost(signature + returned dict;scrape_kwargs_to_api_paramsauto-passes through).write_output()verbose block now surfaces theSpb-auto-costresponse header asAuto Credit Cost, alongsideSpb-cost.src/scrapingbee_cli/client.py—Client.scrape()gainsmode/max_cost; added to the params list._clean_params()dropsNone, so an omitted--max-cost= uncapped for free.tests/unit/test_client.py—TestModeParam+TestMaxCostParam(sent-when-set / omitted-when-unset), mirroringTestTagParamvia patchedclient._get.tests/unit/test_cli.py—TestModeAutoGuards: command-level guard tests (CliRunner + patchedget_api_key) for all conflicting-option combos,--max-costrequiring--mode auto,--max-cost < 1, and the valid pass-through cases.skills/scrapingbee-cli/reference/scrape/options.mdgains a dedicated Auto-Mode section +--mode/--max-costrows;README.mdkey-features bullet;CHANGELOG.md[1.4.5]entry. Propagated to all mirror dirs via./sync-skills.sh.pyproject.toml,__init__.py×2,plugin.json,AGENTS.mdupgrade line, canonical + guardSKILL.mdfrontmatter, synced mirrors).Test plan
pytest -m "not integration"→ 760 passed, 9 deselected.ruff check src tests→ clean.ruff format --check src tests→ clean (after format).check-versionconsistency:pyproject.toml==__init__.py== 1.4.5.scrapingbee --version→1.4.5;scrape --helpshows--mode [auto]and--max-cost INTEGER.Spb-auto-costheader rendering + actual cheapest-config charging).Versioning note
Versioned 1.4.5 off main v1.4.4. The open REPL PR #19 (not a draft, no CI) self-bumped to 1.5.0. If #19 merges first, rebase and re-bump (likely 1.5.1 or 1.6.0) to keep the
check-versionjob green and avoid a duplicate/back-numbered tag — version/CHANGELOG may need amending depending on merge order.Cross-link: #19
🤖 Generated with Claude Code