Crawl · Python
Discover linked pages and extract a small in-memory result set.
In this guide
Purpose and lifecycle
Use follow, limit, depth and concurrency to bound discovery. For a large output dataset, persist discovered URLs and pass them to DatasetJob.
Node run returns DatasetResult[]. Python build returns a CrawlResults wrapper, but the native result conversion currently has a documented mismatch; review known issues.
Persistent crawl frontier state and DatasetJob checkpoint state are different formats and APIs.
Definition and availability
Source snapshot: 1.0.0-alpha.3. Package export. 4 member(s) have a known limitation; see the marked entries below.
Signatures and source locations are generated from the SDK wrappers. Clean snapshots link to the recorded commit. Modified snapshots link to main, which may differ; file hashes identify the local inputs.
class CrawlMembers
| Member | Kind | Return / value type | Source status |
|---|---|---|---|
| __init__ | method | Not annotated; see behavior notes | Present in source |
| resumable | static method | 'Crawl' | Present in source |
| follow | method | 'Crawl' | Present in source |
| with_pagination | method | 'Crawl' | Present in source |
| limit | method | 'Crawl' | Present in source |
| depth | method | 'Crawl' | Known limitation — read entry |
| field | method | 'Crawl' | Present in source |
| auto_match | method | 'Crawl' | Present in source |
| concurrency | method | 'Crawl' | Present in source |
| delay | method | 'Crawl' | Present in source |
| browser | method | 'Crawl' | Present in source |
| respect_robots | method | 'Crawl' | Present in source |
| cancel | method | Not annotated; see behavior notes | Present in source |
| webhook | method | 'Crawl' | Known limitation — read entry |
| schedule | method | Not annotated; see behavior notes | Known limitation — read entry |
| build | method | CrawlResults | Known limitation — read entry |
__init__()
Create a bounded link-discovery builder. Configure fields, page/depth limits and pacing before running it. Python can also wrap a supplied native crawl handle.
Returns / value: Not annotated; see behavior notes.
def __init__(self, start_url: str, session: Optional[Session]=None, _core_crawl=None)| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| start_url | str | Required | Initial page used for crawl discovery. |
| session | Optional[Session] | Default: None | Shared request state. Omit only where the signature provides a default. |
| _core_crawl | Not annotated | Default: None | Optional native crawl handle; normally supplied by the resumable factory. |
resumable()
Use a persistent frontier directory. Python argument order is start_url, path, session; Node order is startUrl, session, path.
Returns / value: 'Crawl'.
def resumable(cls, start_url: str, path: str, session: Optional[Session]=None) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| start_url | str | Required | Initial page used for crawl discovery. |
| path | str | Required | Filesystem path relative to the process working directory unless absolute. |
| session | Optional[Session] | Default: None | Shared request state. Omit only where the signature provides a default. |
follow()
Set the CSS selector for links to enqueue. The link’s href is resolved against the page URL.
Returns / value: 'Crawl'.
def follow(self, selector: str) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| selector | str | Required | Selector evaluated against the fetched DOM. |
with_pagination()
Attach a PaginationConfig built with one of its factories.
Returns / value: 'Crawl'.
def with_pagination(self, config: PaginationConfig) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| config | PaginationConfig | Required | Configuration object; see the linked job or pagination reference. |
limit()
Set a maximum page count for this crawl.
Returns / value: 'Crawl'.
def limit(self, pages: int) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| pages | int | Required | Maximum downstream crawl pages. |
depth()
Known limitation: The wrapper calls native depth(), but PyCrawl exposes max_depth(). This method cannot currently be used through the public wrapper.
Set the maximum link-hop depth from the starting URL.
Returns / value: 'Crawl'.
def depth(self, max_depth: int) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| max_depth | int | Required | Maximum sitemap nesting or crawl depth, according to the API. |
field()
Append an extraction field evaluated on each crawled page.
Returns / value: 'Crawl'.
def field(self, name: str, selector: str, selector_type: str='css', default: Optional[str]=None, extract_type: str='text') -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| name | str | Required | Field, header or attribute name for this operation. |
| selector | str | Required | Selector evaluated against the fetched DOM. |
| selector_type | str | Default: 'css' | Selector engine for this field; supported values differ between builders. |
| default | Optional[str] | Default: None | Fallback field value when extraction is empty. |
| extract_type | str | Default: 'text' | Extraction transformation such as text, price, datetime, url or attr:name, where supported. |
auto_match()
Set heuristic recovery on the associated session.
Returns / value: 'Crawl'.
def auto_match(self, enabled: bool) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| enabled | bool | Required | Enable or disable this behavior. |
concurrency()
Set concurrent crawl workers. Start small and respect source pacing.
Returns / value: 'Crawl'.
def concurrency(self, n: int) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| n | int | Required | Count or index; see the method description. |
delay()
Set request spacing in seconds; this is separate from retry backoff.
Returns / value: 'Crawl'.
def delay(self, seconds: float) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| seconds | float | Required | Time in seconds; see the method-specific range and timing semantics. |
browser()
Choose the browser transport for this session. Requires a browser-enabled native build and local Chromium.
Returns / value: 'Crawl'.
def browser(self, enabled: bool=True) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| enabled | bool | Default: True | Enable or disable this behavior. |
respect_robots()
Set whether robots rules are respected; enabled by default.
Returns / value: 'Crawl'.
def respect_robots(self, enabled: bool) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| enabled | bool | Required | Enable or disable this behavior. |
cancel()
Request cancellation of the crawler. Await completion before restarting or reusing its state.
Returns / value: Not annotated; see behavior notes.
def cancel(self)webhook()
Known limitation: The wrapper calls webhook(), which is not exported by PyCrawl. The Rust and Node APIs expose a webhook setting.
Send results to an application-owned endpoint. Delivery is not an exactly-once queue and has no durable retry receipt API.
Returns / value: 'Crawl'.
def webhook(self, url: str) -> 'Crawl'| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| url | str | Required | HTTP(S) source URL; verify the target is appropriate for your application. |
schedule()
Known limitation: The wrapper calls schedule(), which is not exported by PyCrawl. Use an application scheduler around a supported operation.
Start an unmanaged native background thread that repeats the crawl. Node exposes no stop/join handle for it. Prefer a worker scheduler that owns one run at a time.
Returns / value: Not annotated; see behavior notes.
def schedule(self, interval_seconds: int)| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| interval_seconds | int | Required | Repeat interval in seconds. See lifecycle restrictions before scheduling. |
build()
Known limitation: PyCrawl.build returns dictionaries, while this wrapper constructs DatasetResult objects expecting native result handles. Their to_dict/export calls can fail. Prefer DatasetJob for production file exports.
Run the Python crawl synchronously. Current wrapper/native result types differ; see the known issue on this member.
Returns / value: CrawlResults.
def build(self) -> CrawlResultsErrors and operational limits
Some page failures are logged while crawling continues; Node run does not expose the complete native CrawlResult diagnostics. A result list alone is not proof that every discovered URL succeeded.
Source availability, package publication and runtime validation are separate facts. These pages describe the source snapshot, not a claim that all platforms or every API path have passed production acceptance.