Page · Node.js
Fetch one page and inspect its parsed HTML before defining a dataset schema.
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 PageUsage 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;
}Members
| Member | Kind | Return / value type | Source status |
|---|---|---|---|
| constructor | method | Page | Present in source |
| create | static method | Promise<Page> | Present in source |
| url | property | string | Present in source |
| status | property | number | Present in source |
| html | property | string | Present in source |
| title | method | string | Present in source |
| css | method | ElementCollection | Present in source |
| xpath | method | ElementCollection | Present in source |
| findText | method | ElementCollection | Present in source |
| afterText | method | ElementCollection | Present in source |
| beforeText | method | ElementCollection | Present in source |
| regex | method | ElementCollection | Present in source |
| nativePage | property | JsPage | Present 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| nativePage | JsPage | Required | Existing 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>| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| url | string | Required | HTTP(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; } | undefined | Optional | Optional 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: stringstatus
HTTP response status code.
Returns / value: number.
status: numberhtml
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: stringtitle()
Return the text of the title element, or an empty string when absent.
Returns / value: string.
title(): stringcss()
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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| selector | string | Required | Selector 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| query | string | Required | Supported XPath expression. |
findText()
Find DOM nodes by text content using the engine text selector.
Returns / value: ElementCollection.
findText(text: string): ElementCollection| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| text | string | Required | Text 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| text | string | Required | Text anchor used for matching. |
beforeText()
Select the element before a matching text anchor.
Returns / value: ElementCollection.
beforeText(text: string): ElementCollection| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| text | string | Required | Text 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| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| pattern | string | Required | Rust 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: JsPageErrors 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.