Data Extraction Actions
Actions for reading data from page elements.
getText
Get the text content of an element, without any HTML tags.
Value: string (selector)
<h1 class="title">Welcome to BrowserWorker</h1>
[
{ "getText": "h1.title" }
]
Returns: "Welcome to BrowserWorker"
Save for later use:
[
{ "getText": ".product-price", "options": { "save": "price" } },
{ "fill": ["input#discount", "${price}"] }
]
Append to an array:
[
{ "getText": ".item:nth-child(1)", "options": { "push": "names" } },
{ "getText": ".item:nth-child(2)", "options": { "push": "names" } }
// Get result by getSavedData
{ "getSavedData": "names" }
]
Result of getSavedData:
{
"names": ["Item 1", "Item 2"]
}
Options
| Option | Type | Default | Description |
|---|---|---|---|
save | string | — | Save the result with this key for use with ${key} |
push | string | — | Append the result to an array in the data cache |
waitFor | boolean | true | Wait for the element to appear |
timeout | number | 10000 | How long to wait (ms) |
iframe | string | string[] | — | Look inside an iframe |
getHTML
Get the inner HTML of an element. By default it returns only the contents — use outer: true to get the element itself including its own tag.
Value: string (selector)
<div class="content"><p>Hello <strong>World</strong></p></div>
[
{ "getHTML": ".content" }
]
Returns: "<p>Hello <strong>World</strong></p>"
Include the element's own tag:
[
{
"getHTML": "#article",
"options": { "outer": true, "save": "articleHTML" }
}
]
Options
| Option | Type | Default | Description |
|---|---|---|---|
outer | boolean | false | Return the full element HTML instead of just its contents |
save | string | — | Save the result |
push | string | — | Append to an array |
waitFor | boolean | true | Wait for the element to appear |
timeout | number | 10000 | How long to wait (ms) |
iframe | string | string[] | — | Look inside an iframe |
getAttribute
Get the value of an attribute from an element.
Value: [selector, attribute]
<a class="main-link" href="https://example.com">Visit</a>
[
{ "getAttribute": ["a.main-link", "href"] }
]
Returns: "https://example.com"
Save the result:
[
{ "getAttribute": ["img.avatar", "src"], "options": { "save": "avatarUrl" } }
]
Options
| Option | Type | Default | Description |
|---|---|---|---|
save | string | — | Save the result |
push | string | — | Append to an array |
waitFor | boolean | true | Wait for the element to appear |
timeout | number | 10000 | How long to wait (ms) |
iframe | string | string[] | — | Look inside an iframe |
getValue
Get the current value of a form field (<input>, <textarea>, or <select>).
Value: string (selector)
<input type="email" name="email" value="hello@example.com" />
[
{ "getValue": "input[name=email]" }
]
Returns: "hello@example.com"
Save the result:
[
{ "getValue": "select#country", "options": { "save": "selectedCountry" } }
]
Options
| Option | Type | Default | Description |
|---|---|---|---|
save | string | — | Save the result |
push | string | — | Append to an array |
waitFor | boolean | true | Wait for the element to appear |
timeout | number | 10000 | How long to wait (ms) |
iframe | string | string[] | — | Look inside an iframe |
extractAll
Extract data from multiple matching elements at once. Each matched element becomes one item in the result.
Value: [containerSelector, fieldMap]
<div class="product-card">
<h3>Laptop</h3>
<span class="price">$999</span>
<a href="/laptop">Details</a>
<img src="/img/laptop.jpg" />
</div>
<div class="product-card">
<h3>Phone</h3>
<span class="price">$699</span>
<a href="/phone">Details</a>
<img src="/img/phone.jpg" />
</div>
[
{
"extractAll": [
".product-card",
{
"title": "h3",
"price": ".price",
"link": ["a", "href"],
"image": ["img", "src"]
}
]
}
]
Returns:
[
{ "title": "Laptop", "price": "$999", "link": "/laptop", "image": "/img/laptop.jpg" },
{ "title": "Phone", "price": "$699", "link": "/phone", "image": "/img/phone.jpg" }
]
Field Map Syntax
The second argument defines what to extract. Keys are your field names, values are selectors or [selector, attribute] pairs:
| Format | Description | Example |
|---|---|---|
"selector" | Text content of a child element | "title": "h3" |
["selector", "attr"] | Attribute value of a child element | "link": ["a", "href"] |
":scope > ..." | Select relative to the container element | "desc": ":scope > p" |
[":scope", "attr"] | Attribute on the container element itself | "id": [":scope", "data-id"] |
Using :scope in selectors
Prefix a selector with :scope to match relative to each container, not the whole page. Useful when child elements share the same tag across multiple containers.
<div class="card">
<p>Short intro</p>
<div>
<div>Posted on Jan 1</div>
<div>Read the full article here.</div>
</div>
</div>
[
{
"extractAll": [
".card",
{
"intro": "p",
"description": ":scope > div > div:nth-child(2)"
}
]
}
]
Returns:
[
{ "intro": "Short intro", "description": "Read the full article here." }
]
Using :scope to read container attributes
Use [":scope", "attr"] when the data you need is an attribute on the container element itself, not a child:
<div class="item" data-id="101">
<h3>Laptop</h3>
<span class="price">$999</span>
</div>
<div class="item" data-id="102">
<h3>Phone</h3>
<span class="price">$699</span>
</div>
[
{
"extractAll": [
".item",
{
"id": [":scope", "data-id"],
"title": "h3",
"price": ".price"
}
]
}
]
Returns:
[
{ "id": "101", "title": "Laptop", "price": "$999" },
{ "id": "102", "title": "Phone", "price": "$699" }
]
Extract from a table, limit to 10 rows:
[
{
"extractAll": [
"table tbody tr",
{
"name": "td:nth-child(1)",
"email": "td:nth-child(2)",
"role": "td:nth-child(3)"
}
],
"options": { "limit": 10, "save": "users" }
}
]
Options
| Option | Type | Default | Description |
|---|---|---|---|
limit | number | 0 | Max items to return (0 = no limit) |
save | string | — | Save the result array |
push | string | — | Append to an array |
waitFor | boolean | true | Wait for the container elements to appear |
timeout | number | 10000 | How long to wait (ms) |
getSavedData
Get values you saved earlier in the task. Each key maps to its saved value, or null if it was never set.
Value: string | string[]
Single key:
[
{ "getSavedData": "price" }
]
Multiple keys:
[
{ "getSavedData": ["price", "title", "users"] }
]
Returns:
{
"price": "$19.99",
"title": "Laptop",
"users": null
}
clearSavedData
Delete all saved data. Use this when you want to start fresh mid-task.
Value: true
[
{ "clearSavedData": true }
]
The data cache is cleared automatically in these situations:
- New task starts — cleared at the beginning of every task
- Chrome restarts — cleared on every browser launch
When tasks share the same session.id, the data cache is not cleared between them. This lets you save data in one API call and read it in the next. Use clearSavedData if you want to reset it between session tasks.
See Sessions for details.
Example: Scrape a Product Listing
[
{ "openNewTab": "https://example.com/products" },
{ "waitForElement": ".product-card" },
{
"extractAll": [
".product-card",
{
"name": "h3.product-name",
"price": ".price",
"rating": ".stars",
"url": ["a", "href"],
"image": ["img", "src"]
}
],
"options": { "limit": 20, "save": "products" }
},
{ "getSavedData": ["products"] }
]
Example: Collect Data from a Page
[
{ "openNewTab": "https://example.com/page/1" },
{ "getText": "h1", "options": { "save": "pageTitle" } },
{ "getText": ".result-count", "options": { "save": "totalResults" } },
{ "getAttribute": ["a.next-page", "href"], "options": { "save": "nextPageUrl" } },
{ "getSavedData": ["pageTitle", "totalResults", "nextPageUrl"] }
]