Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ asyncio.run(main())

### Extract

[Extract](https://docs.zenrows.com) (beta) runs a page through Zenrows' AI-powered structured extraction instead of returning raw HTML. Use `client.extract()` — it's the same request as `fetch()`, with the `extract` param set for you (defaults to `"auto"`; pass `"native"` or `"standard"` for the other contracts).
[Extract](https://docs.zenrows.com/extract/introduction) (beta) runs a page through Zenrows' AI-powered structured extraction instead of returning raw HTML. Use `client.extract()` — it's the same request as `fetch()`, with the `extract` param set for you (defaults to `"auto"`; pass `"native"` or `"standard"` for the other contracts).

```python
from zenrows import ZenRowsClient
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ build-backend = "hatchling.build"
[project]
name = "zenrows"
version = "1.6.0"
description = "ZenRows Python SDK — synchronous scraping + Batch (async job) API"
description = "Zenrows Python SDK: Fetch, Extract (structured data), Batch and Crawl APIs"
readme = "README.md"
license = { text = "MIT" }
authors = [
{ name = "ZenRows", email = "support@zenrows.com" },
]
keywords = ["zenrows", "scraper", "scraping", "async", "batch"]
keywords = ["zenrows", "scraper", "scraping", "web-scraping", "extract", "structured-data", "async", "batch", "crawl"]
classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
Expand Down
13 changes: 8 additions & 5 deletions src/zenrows/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ def extract(
or "standard". Thin wrapper over `fetch()` with the `extract` param set —
no separate endpoint or auth.

`mode="auto"` is a domain-gated open beta: when the target domain isn't
enabled yet, the API returns a 402 with `code: "AUTH010"`. By default
this retries once with `autoparse=True` instead of returning the error
response — pass `fallback_to_autoparse=False` to disable that and get
the raw AUTH010 response back.
Extract works on any domain once Zenrows has prepared it, with any
active API key. A domain that isn't prepared yet answers 403 with
`code: "REQS007"`, returned as is; prepare it with
`POST /v1/extract/prepared-domains`. If the API answers with
`code: "AUTH010"` (domain not enabled), this retries once with
`autoparse=True` instead of returning the error response — pass
`fallback_to_autoparse=False` to disable that and get the raw AUTH010
response back.

`adaptive_stealth=True` (default) also sends Adaptive Stealth Mode
(`mode: "auto"` at the wire-param level - unrelated to this method's own
Expand Down
6 changes: 3 additions & 3 deletions tests/test_fetch_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def test_extract_does_not_mutate_caller_supplied_params_dict(self, mock_request)


class TestExtractAutoparseFallback(TestCase):
"""`extract(mode="auto")` is a domain-gated open beta: AUTH010 means the
target domain isn't enabled yet. By default this retries once with
"""`extract(mode="auto")`: AUTH010 means the target domain isn't enabled
for Extract. By default this retries once with
Autoparse instead of raising - same behavior as the CLI's extract
adapter."""

Expand Down Expand Up @@ -173,7 +173,7 @@ def test_402_without_auth010_does_not_fall_back(self, mock_request):
@mock.patch.object(Session, "request")
def test_no_fallback_for_non_auto_mode(self, mock_request):
"""AUTH010 shouldn't trigger a fallback for native/standard modes -
only "auto" is the domain-gated beta path."""
only "auto" takes the fallback path."""
mock_request.return_value = _fake_response(402, b'{"code": "AUTH010"}')

response = self.client.extract(url, mode="native")
Expand Down