Docs/API reference

Crawl · Python

Discover linked pages and extract a small in-memory result set.

Download .md
Developers6 min read20 sections
Source reference · Match your SDK version. Availability and known issues
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 Crawl
python1 lines · copy-ready

Members

MemberKindReturn / value typeSource status
__init__methodNot annotated; see behavior notesPresent in source
resumablestatic method'Crawl'Present in source
followmethod'Crawl'Present in source
with_paginationmethod'Crawl'Present in source
limitmethod'Crawl'Present in source
depthmethod'Crawl'Known limitation — read entry
fieldmethod'Crawl'Present in source
auto_matchmethod'Crawl'Present in source
concurrencymethod'Crawl'Present in source
delaymethod'Crawl'Present in source
browsermethod'Crawl'Present in source
respect_robotsmethod'Crawl'Present in source
cancelmethodNot annotated; see behavior notesPresent in source
webhookmethod'Crawl'Known limitation — read entry
schedulemethodNot annotated; see behavior notesKnown limitation — read entry
buildmethodCrawlResultsKnown 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)
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
start_urlstrRequiredInitial page used for crawl discovery.
sessionOptional[Session]Default: NoneShared request state. Omit only where the signature provides a default.
_core_crawlNot annotatedDefault: NoneOptional 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
start_urlstrRequiredInitial page used for crawl discovery.
pathstrRequiredFilesystem path relative to the process working directory unless absolute.
sessionOptional[Session]Default: NoneShared 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
selectorstrRequiredSelector 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
configPaginationConfigRequiredConfiguration 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
pagesintRequiredMaximum 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
max_depthintRequiredMaximum 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
namestrRequiredField, header or attribute name for this operation.
selectorstrRequiredSelector evaluated against the fetched DOM.
selector_typestrDefault: 'css'Selector engine for this field; supported values differ between builders.
defaultOptional[str]Default: NoneFallback field value when extraction is empty.
extract_typestrDefault: '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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
enabledboolRequiredEnable or disable this behavior.

concurrency()

Set concurrent crawl workers. Start small and respect source pacing.

Returns / value: 'Crawl'.

def concurrency(self, n: int) -> 'Crawl'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
nintRequiredCount 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
secondsfloatRequiredTime 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
enabledboolDefault: TrueEnable 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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
enabledboolRequiredEnable 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)
python1 lines · copy-ready

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'
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
urlstrRequiredHTTP(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)
python1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
interval_secondsintRequiredRepeat 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) -> CrawlResults
python1 lines · copy-ready

Errors 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.