Docs/API reference

Sitemap · Node.js

Discover URLs from a sitemap or use them to seed a bounded crawl.

Download .md
Developers4 min read16 sections
Source reference · Match your SDK version. Availability and known issues
In this guide

Purpose and lifecycle

listUrls/list_urls returns an in-memory list of sitemap entries. It does not fetch each listed page.

maxDepth/max_depth limits sitemap-index recursion. depth limits subsequent crawling from each seed; these limits have different meanings.

For a large dataset, persist discovered URLs to a file and use DatasetJob. Inspect gzip and child-sitemap handling for your binding before relying on compressed sitemap support.

Definition and availability

Source snapshot: 1.0.0-alpha.3. Package export. Declared in source; this is not a runtime test result.

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 Sitemap
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 { Sitemap } from 'crawlingo';
import { writeFileSync } from 'node:fs';
const entries = await new Sitemap('https://example.com/sitemap.xml').maxDepth(3).listUrls();
writeFileSync('urls.txt', entries.map(entry => entry.loc).join('\n') + '\n');
typescript4 lines · copy-ready

Members

MemberKindReturn / value typeSource status
constructormethodSitemapPresent in source
maxDepthmethodthisPresent in source
followmethodthisPresent in source
limitmethodthisPresent in source
depthmethodthisPresent in source
concurrencymethodthisPresent in source
delaymethodthisPresent in source
fieldmethodthisPresent in source
webhookmethodthisPresent in source
listUrlsmethodPromise<SitemapEntry[]>Present in source
buildmethodPromise<DatasetResult[]>Present in source

constructor()

Create a sitemap discovery builder. Fetching begins with listUrls/list_urls or build; the constructor does not materialize discovered URLs.

Returns / value: Sitemap.

constructor(sitemapUrl: string, opts?: { session?: Session; }): Sitemap
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
sitemapUrlstringRequiredURL of a sitemap XML document or index.
opts{ session?: Session; }Default: {}Optional extraction settings; use only the keys declared by this method.

maxDepth()

Maximum sitemap-index nesting depth.

Returns / value: this.

maxDepth(depth: number): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
depthnumberRequiredNesting or crawl-hop limit, as specified by this method.

follow()

Configure links followed after a seed page is fetched.

Returns / value: this.

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

limit()

Configure the downstream crawl page limit.

Returns / value: this.

limit(pages: number): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
pagesnumberRequiredMaximum downstream crawl pages.

depth()

Configure the downstream crawl hop limit.

Returns / value: this.

depth(maxDepth: number): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
maxDepthnumberRequiredMaximum sitemap nesting or crawl depth, according to the API.

concurrency()

Configure concurrent downstream crawl workers.

Returns / value: this.

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

delay()

Configure downstream crawl delay in seconds.

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()

Add a downstream extraction field.

Returns / value: this.

field(name: string, selector: string, selectorType?: string, defaultValue?: string): this
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
namestringRequiredField, header or attribute name for this operation.
selectorstringRequiredSelector evaluated against the fetched DOM.
selectorTypestringDefault: 'css'Selector engine for this field; supported values differ between builders.
defaultValuestring | undefinedOptionalFallback string when extraction produces no value.

webhook()

Set a downstream result endpoint; delivery is not durable.

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.

listUrls()

Fetch sitemap documents and return discovered URL entries; results are collected in memory.

Returns / value: Promise<SitemapEntry[]>.

listUrls(): Promise<SitemapEntry[]>
typescript1 lines · copy-ready

build()

Seed a crawl with sitemap URLs and return its in-memory results.

Returns / value: Promise<DatasetResult[]>.

build(): Promise<DatasetResult[]>
typescript1 lines · copy-ready

Errors and operational limits

Node listUrls now propagates fetch/parse errors. Python list_urls can skip failing sitemap fetches in its native binding. Empty results can therefore have different meanings.

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.