Skip to content

Actions DSL

Markdown agents.txt

The actions field is a tree. Leaves extract values; branches recurse into matched elements; fn nodes are imperative steps (mostly browser; see the matrix below).

CSS is the default selector syntax. Prefer bare selectors (h1, a.cta) — do not prefix with css= (accepted but redundant). Use xpath= for XPath. jQuery extensions (:contains(), :eq(), …) are not supported and throw at runtime.

h1 → text of the first <h1> (default extractor: text)
a.primary@href → absolutized href
xpath=//*[@id='x']@html → outer HTML
"div[data-x='@']"@text → quoting lets you put '@' inside the selector

Full string form: [scheme=]<selector>@<extractor>.

  • Scheme — omit (css default) or xpath= / text=.
  • Selector — standard CSS or XPath. Wrap in quotes if it contains @.
  • Extractor — what to pull (see table). Defaults to text.
ExtractorReturnsNotes
text / textOriginalstringVisible text (text trims).
html / innerHtmlstringOuter / inner HTML.
md / fitMdstringElement as Markdown; fitMd strips boilerplate harder.
valuestring | nullInput value. Browser engine.
tagNamestringe.g. "div".
cssSelectorstringA CSS path for the matched element.
json / json:<path>unknownParse text as JSON; optional path drill. See JSON paths.
attributesRecord<string, string>All DOM attributes.
href / hrefOriginalstringAbsolutized (Original = raw). Same pattern for src / poster / srcset.
table / tableJson / tableArrayrowsoptions.headers = false → 2D array.
screenshotstringDeterministic browser only — public PNG URL by default (returnType: 'dataUrl' for base64).
anything elsestring | nullNamed DOM attribute via getAttribute.

context / ocr / htmlTree are not supported in v2.

{
"cards": {
"selector": ".sf-card",
"many": true,
"output": {
"title": "a.sf-title@text",
"link": "a.sf-title@href",
"points": ".sf-points"
}
}
}
  • many: true — apply once per match → array.
  • many: false (default) — first match only.
  • Nested branches are relative to the matched element.
FormExampleHow the string is read
Flat string{ "selector": "a", "many": true, "output": "href" }"href" = extractor name on each match
Nested self{ "selector": "a", "many": true, "output": { "url": "@href", "label": "@text" } }Leading @ = extractor on this match
Nested child{ "selector": "li", "many": true, "output": { "link": "a@href" } }Look up descendant a (first match only)
Nested list{ "output": { "tags": { "selector": "a.tag", "many": true, "output": "text" } } }Array of values inside each row
Nested bug (scalar){ "output": { "tags": "a.tag@text" } }First tag only — not an array
Nested bug (null){ "output": { "url": "href", "label": "text" } }CSS for <href>/<text>null

String nested leaves never return arrays. For list fields inside a row (tags, chips, multi-images), use object form + many: true.

Always model multi-field rows as one nested many: true action. Never parallel arrays (titles[] + authors[]) — they desync when a selector misses a row.

FormReturnsExample
Dot / bracketscalarjson:items.0.name
JSONPath (*, .., or $…)array of matchesjson:items[*].name

When selector ends in @json:<path> and output is an object, each row is projected. Leaf strings are row-relative JSON paths (no @@ means DOM extractors and is rejected here).

{
"images": {
"selector": "body@json:products[*].images[*]",
"output": { "pos": "position", "src": "src" }
}
}
{
"login": { "fn": "fill", "selector": "input[name=email]", "args": "ada@example.com" },
"submit": { "fn": "click", "selector": "button[type=submit]" },
"wait": { "fn": "wait", "args": 1500 }
}

Keys run top-to-bottom; fn nodes sequence side effects.

fn / extractorhtmlbrowser
waitRejected — HTML engine, use browserYes
gotoRejectedYes
backRejectedYes
forwardRejectedYes
clickRejectedYes
fillRejectedYes
selectOptionRejectedYes
2faRejectedYes (otpauth only)
evaluateBoth — JSDOM eval, sync only (no async / Promise)Page evaluate; async allowed, 60s timeout
screenshot extractorNot supported — use browserYes (PNG URL, or returnType: "dataUrl")

Engine pick and request options: Engines.

Per-action options:

FieldMeaning
timeoutPer-action ms (caps apply).
filterRegex; value must match. On flat many, drops non-matches.
matchRegex; return first capture group (or full match).
maxCharsCap string length after match/filter (+head / −tail).
headerstableJson: false → 2D array.
excludeTags / includeTagsmd / fitMd / html strip lists.
returnType / fullPageScreenshot only.

Top-level request options (sibling of actions): waitFor, timeoutMs, resolution, headless, blockAds — see Engines.

Static list — html against /fixtures/listing:

{
"url": "https://scrapesilo.com/fixtures/listing",
"engine": "html",
"actions": {
"cards": {
"selector": ".sf-card",
"many": true,
"output": {
"title": "a.sf-title@text",
"link": "a.sf-title@href",
"points": ".sf-points"
}
}
}
}

Interaction — browser against /fixtures/form (fill + click, then extract):

{
"url": "https://scrapesilo.com/fixtures/form",
"engine": "browser",
"actions": {
"type": { "fn": "fill", "selector": "#sf-q", "args": "widget" },
"submit": { "fn": "click", "selector": "#sf-submit" },
"title": ".sf-result-title",
"count": ".sf-result-count"
}
}

Write actions yourself. For interpretation (outline, summary, “is X present?”), use POST /analyse — not scrape, and not a query field on /scrape.

ScrapeSilo actions DSL (POST /scrape). Required: url, engine ("html"|"browser"), actions. No query. No engine "ai".
Rules:
- CSS is the default selector syntax. Write h1, not css=h1. Use xpath= only when needed. No jQuery (:contains, :eq) — they throw.
- String leaf: "selector@extractor" (default extractor: text). Example: a.sf-cta@href
- Rows: one nested { selector, many: true, output: { ... } }. Never parallel arrays (titles[] + authors[]).
- List field inside a row needs object form + many: true. A string leaf is first-match only.
- Extractor on the matched element itself needs a leading @ in nested output ({ "url": "@href" }). Bare "href" is CSS for a <href> tag → null.
- html fn limits: wait/goto/back/forward/click/fill/selectOption/2fa are rejected. evaluate is sync JSDOM only. screenshot extractor is browser only.
- Interpretation (outline, summary) → POST /analyse, not scrape.
html (static list):
{
"url": "https://scrapesilo.com/fixtures/listing",
"engine": "html",
"actions": {
"cards": {
"selector": ".sf-card",
"many": true,
"output": {
"title": "a.sf-title@text",
"link": "a.sf-title@href",
"points": ".sf-points"
}
}
}
}
browser (fill + click):
{
"url": "https://scrapesilo.com/fixtures/form",
"engine": "browser",
"actions": {
"type": { "fn": "fill", "selector": "#sf-q", "args": "widget" },
"submit": { "fn": "click", "selector": "#sf-submit" },
"title": ".sf-result-title",
"count": ".sf-result-count"
}
}