Crawl · Node.js
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. 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 CrawlUsage 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()));Members
| Member | Kind | Return / value type | Source status |
|---|---|---|---|
| constructor | method | Crawl | Present in source |
| resumable | static method | Crawl | Present in source |
| autoMatch | method | this | Present in source |
| follow | method | this | Present in source |
| withPagination | method | this | Present in source |
| limit | method | this | Present in source |
| depth | method | this | Present in source |
| concurrency | method | this | Present in source |
| delay | method | this | Present in source |
| field | method | this | Present in source |
| webhook | method | this | Present in source |
| schedule | method | void | Known limitation — read entry |
| run | method | Promise<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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| startUrl | string | Required | Initial page used for crawl discovery. |
| session | Session | undefined | Optional | Shared request state. Omit only where the signature provides a default. |
| inner | JsCrawl | undefined | Optional | Existing 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| startUrl | string | Required | Initial page used for crawl discovery. |
| session | Session | Required | Shared request state. Omit only where the signature provides a default. |
| path | string | Required | Filesystem path relative to the process working directory unless absolute. |
autoMatch()
Set heuristic recovery on the associated session.
Returns / value: this.
autoMatch(enabled: boolean): this| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| enabled | boolean | Required | Enable 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| selector | string | Required | Selector evaluated against the fetched DOM. |
withPagination()
Attach a PaginationConfig built with one of its factories.
Returns / value: this.
withPagination(config: PaginationConfig): this| 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: this.
limit(limitNum: number): this| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| limitNum | number | Required | Maximum number of pages to collect. |
depth()
Set the maximum link-hop depth from the starting URL.
Returns / value: this.
depth(depthNum: number): this| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| depthNum | number | Required | Maximum link-following depth from seed pages. |
concurrency()
Set concurrent crawl workers. Start small and respect source pacing.
Returns / value: this.
concurrency(n: number): this| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| n | number | Required | Count 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| seconds | number | Required | Time 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| name | string | Required | Field, header or attribute name for this operation. |
| selector | string | Required | Selector evaluated against the fetched DOM. |
| options | { selectorType?: "css" | "xpath"; defaultVal?: string; } | undefined | Optional | Optional 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| url | string | Required | HTTP(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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| intervalSeconds | number | Required | Repeat 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[]>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.