Docs/API reference

Page · Node.js

Fetch one page and inspect its parsed HTML before defining a dataset schema.

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

Purpose and lifecycle

Python Page(url) is lazy; reading status, html or selectors triggers loading. Python Page.create fetches immediately. Node Page.create returns a promise; the Node constructor accepts an existing native page.

A page retains HTML and a DOM tree. Use DatasetJob for large inputs rather than keeping a list of Page objects.

HTTP statuses such as 404, 429 and 500 are returned through status, including after retries are exhausted. They do not automatically become typed HTTP exceptions.

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 Page
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 { Page, Session, TimeoutError } from 'crawlingo';
try {
  const page = await Page.create('https://example.com/', { session: new Session().retries(1) });
  console.log(page.status, page.css('h1').text);
} catch (error) {
  if (error instanceof TimeoutError) console.error(error.seconds);
  else throw error;
}
typescript8 lines · copy-ready

Members

MemberKindReturn / value typeSource status
constructormethodPagePresent in source
createstatic methodPromise<Page>Present in source
urlpropertystringPresent in source
statuspropertynumberPresent in source
htmlpropertystringPresent in source
titlemethodstringPresent in source
cssmethodElementCollectionPresent in source
xpathmethodElementCollectionPresent in source
findTextmethodElementCollectionPresent in source
afterTextmethodElementCollectionPresent in source
beforeTextmethodElementCollectionPresent in source
regexmethodElementCollectionPresent in source
nativePagepropertyJsPagePresent in source

constructor()

Native interop entry point. Applications normally obtain this wrapper from Page.create, a selector or Dataset.build; do not pass a URL or an arbitrary object as a native handle.

Returns / value: Page.

constructor(nativePage: JsPage): Page
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
nativePageJsPageRequiredExisting native page handle; applications should normally call Page.create.

create()

Fetch and parse the URL. Node request headers/cookies merge over the session defaults; explicit timeout, proxy and profile take precedence. Python passes its Page defaults to native code, including 30 seconds and 3 retries.

Returns / value: Promise<Page>.

create(url: string, options?: { autoMatch?: boolean; timeout?: number; headers?: Record<string, string>; cookies?: Record<string, string>; proxy?: string; browserProfile?: string; session?: Session; }): Promise<Page>
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
urlstringRequiredHTTP(S) source URL; verify the target is appropriate for your application.
options{ autoMatch?: boolean; timeout?: number; headers?: Record<string, string>; cookies?: Record<string, string>; proxy?: string; browserProfile?: string; session?: Session; } | undefinedOptionalOptional settings object. Its inline signature lists the accepted keys and types.

url

Source/final URL according to the operation; check redirects and provenance needs.

Returns / value: string.

url: string
typescript1 lines · copy-ready

status

HTTP response status code.

Returns / value: number.

status: number
typescript1 lines · copy-ready

html

Load the page if necessary and return its HTML string. Inspect status separately; an HTTP error response can still have a body.

Returns / value: string.

html: string
typescript1 lines · copy-ready

title()

Return the text of the title element, or an empty string when absent.

Returns / value: string.

title(): string
typescript1 lines · copy-ready

css()

Evaluate the supported CSS subset and return a collection in document order. This is not a browser querySelectorAll implementation.

Returns / value: ElementCollection.

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

xpath()

Evaluate the supported basic XPath subset; advanced XPath axes/functions are not implemented.

Returns / value: ElementCollection.

xpath(query: string): ElementCollection
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
querystringRequiredSupported XPath expression.

findText()

Find DOM nodes by text content using the engine text selector.

Returns / value: ElementCollection.

findText(text: string): ElementCollection
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
textstringRequiredText anchor used for matching.

afterText()

Select the element after a matching text anchor; inspect sample output before relying on a repeated label.

Returns / value: ElementCollection.

afterText(text: string): ElementCollection
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
textstringRequiredText anchor used for matching.

beforeText()

Select the element before a matching text anchor.

Returns / value: ElementCollection.

beforeText(text: string): ElementCollection
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
textstringRequiredText anchor used for matching.

regex()

Compile the Rust regular expression and match text. Invalid syntax produces SelectorError. Rust regex does not support look-around or backreferences.

Returns / value: ElementCollection.

regex(pattern: string): ElementCollection
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
patternstringRequiredRust regular expression.

nativePage

Native interop entry point. Applications normally obtain this wrapper from Page.create, a selector or Dataset.build; do not pass a URL or an arbitrary object as a native handle.

Returns / value: JsPage.

public readonly nativePage: JsPage
typescript1 lines · copy-ready

Errors and operational limits

Network failures reject/raise. Node maps native timeout, DNS and regex selector failures to typed errors. Missing selector matches return an empty collection. Python exception conversion is message-based.

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.