Python SDK: Node: a page element
Dom.q() returns one element or None; Dom.qa() returns an array. Check for a missing element before reading it.
Examples are fragments inside def run(ctx):. All SDK methods are synchronous; do not add await.
Obtaining the SDK object
node = ctx.dom('<a href="/product">Product</a>', 'https://example.com').q('a')
if node is None:
return
Methods
text
node.text(trim=True) -> str
| Argument | Type | Required | Purpose |
|---|---|---|---|
trim |
bool |
No, see the signature default | Trim surrounding whitespace. |
Result: str.
Get the found element's text. Repeated spaces and line breaks are combined.
result = node.text()
html
node.html() -> str
No arguments.
Result: str.
Get the whole element's HTML, including its own tag.
result = node.html()
attr
node.attr(name) -> str | None
| Argument | Type | Required | Purpose |
|---|---|---|---|
name |
str |
Yes | Field, header, file, credential, or metric name, depending on the method. |
Result: str | None.
Get the value of one attribute.
result = node.attr('href')
abs
node.abs(name='href') -> str | None
| Argument | Type | Required | Purpose |
|---|---|---|---|
name |
str |
No, see the signature default | Field, header, file, credential, or metric name, depending on the method. |
Result: str | None.
Get an absolute URL from an attribute. href is used by default.
result = node.abs('href')
q
node.q(selector) -> Node | None
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
Result: Node | None. An SDK object; use its methods instead of emitting it directly.
Find the first matching element inside the current fragment.
result = node.q('.price')
qa
node.qa(selector) -> list[Node]
| Argument | Type | Required | Purpose |
|---|---|---|---|
selector |
str |
Yes | CSS selector. |
Result: list[Node].
Get all matches inside the current fragment.
result = node.qa('a')
exists
node.exists() -> bool
No arguments.
Result: bool.
Check that an obtained Node exists.
result = node.exists()
Errors and execution context
All calls are synchronous. Invalid arguments or malformed source data can raise ValueError/TypeError; a platform refusal or unavailable service raises RuntimeError. Missing elements/values return None or an empty collection only where explicitly documented. Do not convert every exception into an empty successful result. External-service methods are unavailable in export transformations; see transformation limits and environment.