Docs/API reference

Crawl · Node.js

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

Download .md
Developers5 min read18 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. 1 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.

export class Crawl
typescript1 lines · copy-ready

Usage example

Use a matching source build. Where a snippet uses page, obtain it with the Page example first. Example URLs illustrate API shape; they are not promised datasets.

import { Crawl, Session } from 'crawlingo';
const results = await new Crawl('https://example.com/', new Session().rateLimit(1))
  .follow('a').limit(10).depth(1).concurrency(2)
  .field('title', 'h1').run();
console.log(results.map(result => result.toDict()));
typescript5 lines · copy-ready

Members

MemberKindReturn / value typeSource status
constructormethodCrawlPresent in source
resumablestatic methodCrawlPresent in source
autoMatchmethodthisPresent in source
followmethodthisPresent in source
withPaginationmethodthisPresent in source
limitmethodthisPresent in source
depthmethodthisPresent in source
concurrencymethodthisPresent in source
delaymethodthisPresent in source
fieldmethodthisPresent in source
webhookmethodthisPresent in source
schedulemethodvoidKnown limitation — read entry
runmethodPromise<DatasetResult[]>Present in source

constructor()

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: Crawl.

constructor(startUrl: string, session?: Session, inner?: JsCrawl): Crawl
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
startUrlstringRequiredInitial page used for crawl discovery.
sessionSession | undefinedOptionalShared request state. Omit only where the signature provides a default.
innerJsCrawl | undefinedOptionalExisting native handle for wrapper interop; not a URL or plain data object.

resumable()

Use a persistent frontier directory. Python argument order is start_url, path, session; Node order is startUrl, session, path.

Returns / value: Crawl.

resumable(startUrl: string, session: Session, path: string): Crawl
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
startUrlstringRequiredInitial page used for crawl discovery.
sessionSessionRequiredShared request state. Omit only where the signature provides a default.
pathstringRequiredFilesystem path relative to the process working directory unless absolute.

autoMatch()

Set heuristic recovery on the associated session.

Returns / value: this.

autoMatch(enabled: boolean): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
enabledbooleanRequiredEnable or disable this behavior.

follow()

Set the CSS selector for links to enqueue. The link’s href is resolved against the page URL.

Returns / value: this.

follow(selector: string): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
selectorstringRequiredSelector evaluated against the fetched DOM.

withPagination()

Attach a PaginationConfig built with one of its factories.

Returns / value: this.

withPagination(config: PaginationConfig): this
typescript1 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: this.

limit(limitNum: number): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
limitNumnumberRequiredMaximum number of pages to collect.

depth()

Set the maximum link-hop depth from the starting URL.

Returns / value: this.

depth(depthNum: number): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
depthNumnumberRequiredMaximum link-following depth from seed pages.

concurrency()

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

Returns / value: this.

concurrency(n: number): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
nnumberRequiredCount or index; see the method description.

delay()

Set request spacing in seconds; this is separate from retry backoff.

Returns / value: this.

delay(seconds: number): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
secondsnumberRequiredTime in seconds; see the method-specific range and timing semantics.

field()

Append an extraction field evaluated on each crawled page.

Returns / value: this.

field(name: string, selector: string, options?: { selectorType?: "css" | "xpath"; defaultVal?: string; }): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
namestringRequiredField, header or attribute name for this operation.
selectorstringRequiredSelector evaluated against the fetched DOM.
options{ selectorType?: "css" | "xpath"; defaultVal?: string; } | undefinedOptionalOptional settings object. Its inline signature lists the accepted keys and types.

webhook()

Send results to an application-owned endpoint. Delivery is not an exactly-once queue and has no durable retry receipt API.

Returns / value: this.

webhook(url: string): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
urlstringRequiredHTTP(S) source URL; verify the target is appropriate for your application.

schedule()

Known limitation: A background native loop is started without a public cancellation/join handle. Use an external scheduler for controlled worker lifecycle.

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: void.

schedule(intervalSeconds: number): void
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
intervalSecondsnumberRequiredRepeat interval in seconds. See lifecycle restrictions before scheduling.

run()

Return all successful result wrappers in memory. This is not a disk-sharded bulk job.

Returns / value: Promise<DatasetResult[]>.

run(): Promise<DatasetResult[]>
typescript1 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.