Docs/API reference

Element · Node.js

Read one selected DOM element and its attributes.

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

Purpose and lifecycle

Obtain elements from a Page collection rather than constructing wrappers around native handles yourself.

Node uses text and html properties. Python uses text() and html() methods and exposes additional traversal helpers. Python Element is available through crawlingo.element and as a collection result, not as a top-level import.

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 Element
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.

const heading = page.css('h1').first();
if (heading) console.log(heading.text, heading.attr('id'));
typescript2 lines · copy-ready

Members

MemberKindReturn / value typeSource status
constructormethodElementPresent in source
textpropertystringPresent in source
htmlpropertystringPresent in source
attrmethodstring | nullPresent 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: Element.

constructor(inner: JsElement): Element
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
innerJsElementRequiredExisting native handle for wrapper interop; not a URL or plain data object.

text

Read descendant text in document order. Python after-extract hooks apply to this value.

Returns / value: string.

text: string
typescript1 lines · copy-ready

html

Read the reconstructed outer HTML for the selected node.

Returns / value: string.

html: string
typescript1 lines · copy-ready

attr()

Look up one attribute by name. Missing values return null in Node or None in Python.

Returns / value: string | null.

attr(name: string): string | null
typescript1 lines · copy-ready
ParameterTypeRequired / defaultMeaning
namestringRequiredField, header or attribute name for this operation.

Errors and operational limits

Absent attributes and absent relatives may return null/None even where a Python annotation is narrower. Node exposes only text, html and attr; do not translate Python traversal calls directly.

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.