Python SDK: TextTools: text, prices, and numbers
ctx.text() processes values already retrieved. These methods make no network requests.
Examples are fragments inside def run(ctx):. All SDK methods are synchronous; do not add await.
Methods
clean
ctx.text().clean(value) -> str
| Argument | Type | Required | Purpose |
|---|---|---|---|
value |
Any |
Yes | Method-specific value; see its result description. |
Result: str.
Remove HTML tags, repeated spaces, and surrounding whitespace.
result = ctx.text().clean('<b>Product</b>')
money
ctx.text().money(value) -> float | None
| Argument | Type | Required | Purpose |
|---|---|---|---|
value |
Any |
Yes | Method-specific value; see its result description. |
Result: float | None.
Turn a price string into a number, accounting for spaces, a comma, and a currency symbol.
result = ctx.text().money('1 250,50 RUB')
digits
ctx.text().digits(value) -> str
| Argument | Type | Required | Purpose |
|---|---|---|---|
value |
Any |
Yes | Method-specific value; see its result description. |
Result: str.
Keep digits only.
result = ctx.text().digits('SKU 123')
between
ctx.text().between(subject, start, end) -> str | None
| Argument | Type | Required | Purpose |
|---|---|---|---|
subject |
str |
Yes | String being searched. |
start |
int | str |
Yes | Start bound: page number or opening text delimiter. |
end |
int | str |
Yes | End bound: inclusive page number or closing text delimiter. |
Result: str | None.
Take text between the first occurrence of start and the following occurrence of end.
result = ctx.text().between('Price 1250 RUB', 'Price ', ' RUB')
extract
ctx.text().extract(expression, subject, group=1) -> str | None
| Argument | Type | Required | Purpose |
|---|---|---|---|
expression |
str |
Yes | Python regular expression. |
subject |
str |
Yes | String being searched. |
group |
int |
No, see the signature default | Regular-expression capture group number. |
Result: str | None.
Take one group from the first regular expression match.
result = ctx.text().extract(r'(\d+)', 'Price 1250', 1)
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.